Questions tagged [simplemodal]

Overview

SimpleModal is a lightweight jQuery plugin which provides a powerful interface for modal dialog development. Think of it as a modal dialog framework. SimpleModal gives you the flexibility to build whatever you can envision, while shielding you from related cross-browser issues inherent with UI development.

Usage

SimpleModal provides two simple ways to invoke a modal dialog.

As a chained jQuery function, you can call the modal() function on a jQuery element and a modal dialog will be displayed using the contents of that element. For example:

$("#element-id").modal();

As a stand-alone function, a modal dialog can be created by passing a jQuery object, a DOM element, or a plain string (which can contain HTML). For example:

$.modal("<div><h1>SimpleModal</h1></div>");

Both of the methods described above, also accept an optional options object (nice tongue-twister, huh?). Using the examples above:

$("#element-id").modal({options});
$.modal("<div><h1>SimpleModal</h1></div>", {options});

Because SimpleModal is more of a modal dialog framework, both of the examples above would create very basic, unstyled, modal dialogs. Styling can be done through external CSS or through properties in the options object. See the Options section below for a detailed list of the available options.

Styling

Styles can be applied through external CSS, the options object, or both. The CSS options for the modal overlay, container, and data elements are: overlayCss, containerCss and dataCss, all which take a key/value object of properties. See the jQuery CSS documentation for details.

SimpleModal handles setting the necessary CSS for displaying the modal dialog. In addition, SimpleModal dynamically centers the modal dialog, unless the position option is used, which takes precedence.

SimpleModal internally defines the following CSS classes: simplemodal-overlay, simplemodal-container, simplemodal-wrap (SimpleModal will automatically set the overflow to auto if the content gets larger than the container), and simplemodal-data.

  • Note: SimpleModal's default closeHTML option declares the modalCloseImg class in order to display an image for closing the dialog. Download the image. Because it is defined in an option, it cannot be styled through the options - an external CSS definition is required:

    #simplemodal-container a.modalCloseImg {
        background:url(/img/x.png) no-repeat; /* Adjust URL as required */
        width:25px;
        height:29px;
        display:inline;
        z-index:3200;
        position:absolute;
        top:-15px;
        right:-18px;
        cursor:pointer;
    }
    

For Internet Explorer 6, you might want to apply the PNG fix:

<!--[if lt IE 7]>
<style type='text/css'>
    #simplemodal-container a.modalCloseImg {
        background:none;
        right:-14px;
        width:22px;
        height:26px;
        filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
            src='img/x.png', sizingMethod='scale'
        );
    }
</style>
<![endif]-->

Demos

In addition to the examples below, I have a collection of demos that feature the different capabilities of SimpleModal:

View Demos

Download

SimpleModal is hosted on Google Code:

Download SimpleModal

There are two versions available; a full source version that contains comments and is formatted for readability, and a minified version with all comments and formatting removed. The full version is recommended for learning and testing, the minified version is for production use.

Archives

Previous version of SimpleModal documentation: v1.2.x, v1.1.x, v1.0.x.

Source

687 questions
5
votes
1 answer

simplemodal contact form passing HTML variables to JAVASCRIPT and to PHP

I'm new to javascript, with some experience in PHP, working mostly with HTML and css styles. I downloaded the simplemodal contact form from Eric Martin's website which looks very nice. I was able to implement the modal pop-up contact form in a…
cameglio
  • 53
  • 3
5
votes
1 answer

jQuery Cycle Plugin Not Working Inside of Modal Box (Simple Modal Plugin)

I'm developing a Wordpress theme that opens new posts in modal boxes instead of separate pages. The image slideshow plugin I'm using to display images for each post (jQuery Cycle Plugin) works great when the post is on its own page, but when using…
Danny Cooper
  • 355
  • 1
  • 8
  • 25
5
votes
1 answer

SimpleModal doesn't work in IE 9 (inside Iframe)

I'm getting following error when using IE 9 (Chrome and FireFox works great): SCRIPT438: Object doesn't support property or method 'removeExpression' jquery.simplemodal.1.4.2.min.js, line 16 character 133 Simple Modal is called inside Iframe.…
Ranaghar
  • 51
  • 1
  • 4
4
votes
2 answers

simple modal not scroll background

I'm using simple modal. Is there any way to keep the background (behind the overlay) from scrolling when you roll the mouse wheel while outside the boundaries of the modal? Thanks!
1252748
  • 14,597
  • 32
  • 109
  • 229
4
votes
3 answers

tab order for links in a simplemodal dialog

I am using the excellent jquery.simplemodal dialog plugin to show a list of items. These items contain hyperlinks. It all works great except that the links in the modal dialog arent coming up as part of the tab order. I have tried setting tabindex…
Andrew Bucknell
  • 1,880
  • 3
  • 21
  • 32
4
votes
2 answers

multiple jQuery simple modal boxes

How would you utilize the jQuery simple modal box, for multiple instances on one page, with unique content for each description?? Would I use the .this function? html:
tony noriega
  • 7,523
  • 17
  • 53
  • 72
4
votes
3 answers

JQuery Autocomplete inside SimpleModal

I have a simple textbox with JQuery autocomplete inside a div on which I use SimpleModal to make a modal dialogue. The first time the modal dialogue is called, the autocomplete works fine. After the dialogue is closed it completely stops working.…
yu_ominae
  • 2,975
  • 6
  • 39
  • 76
4
votes
1 answer

Integrate Ant Design Form with Modal

I am pretty new to React and JS, and I am currently trying to create a component to integrate the antd form with modal so that I could utilize the form functionalities such as "validation". Here is my code: The function to post the request: import…
gangdou
  • 123
  • 2
  • 6
4
votes
1 answer

Data binding does not work after simple modal popup

Please consider the following code (also in this fiddle): var viewModel = { count:ko.observable(0), add:function (){ this.count(this.count()+1); }, popup:function (){ $.modal($("#divPopup")); …
Sxd
  • 153
  • 2
  • 8
4
votes
0 answers

How to make a simple modal window?

guys! Can anyone help to understand how to make a simple modal window? Like to make a fade out background of the web page's content and show a white layer focusing action on it. I'm going to put on that white focused layer turing number form with…
ilnur777
  • 1,135
  • 5
  • 16
  • 28
4
votes
1 answer

SimpleModal-container positioning

I am still a relative beginner with jquery so any help is gratefully appreciated. I took the simplemodal function and changed the positioning from fixed to absolute as I wanted the modal box to be able to be scrolled with the background page. This…
Loonytoons
  • 43
  • 1
  • 3
4
votes
2 answers

how use scroll with simpleModal plugin

I'm using simpleModal plugin http://www.ericmmartin.com/projects/simplemodal/ when the text in the dialog is too long, I try to scroll, but the entire page is scrolling, even when using modal:true. so I can't see the end of the dialog , I try…
Gooloosh
  • 131
  • 1
  • 11
4
votes
4 answers

SimpleModal - closing iframe with close button

So I've searched around and I couldn't find a definitive answer. I want my iframe to have a close button so that users can click it instead of going with the ESC key to close the SimpleModal container. I've tried several things, but it doesn't seem…
Dusan
  • 43
  • 1
  • 4
4
votes
4 answers

Jquery simplemodal close existing modal and open a new one?

Alright, so all modals already have an image at the top right to close them. How can I make additionally another anchor to do the same thing? I thought I could use the "closeClass" option which default to "simplemodal-close" and just add that class…
Matthew
  • 15,282
  • 27
  • 88
  • 123
4
votes
2 answers

JQuery SimpleModal crashing on close in windows w/ safari

I'm leveraging SimpleModal on a small thing I'm working on to open an iFrame and later close it. Says to post here if having issues so here I am. I'm having issues with the simple modal plug-in for jquery when I go to close the popup, but only on…
Izerous
  • 41
  • 2
1
2
3
45 46