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
25
votes
10 answers

SimpleModal breaks ASP.Net Postbacks

I'm using jQuery and SimpleModal in an ASP.Net project to make some nice dialogs for a web app. Unfortunately, any buttons in a modal dialog can no longer execute their postbacks, which is not really acceptable. There is one source I've found with…
tghw
  • 25,208
  • 13
  • 70
  • 96
23
votes
4 answers

How do you close a jQuery Simplemodal?

I want to close a Simplemodal window from a JavaScript function that gets called automatically after a form is submitted and the results recived (AJAX), using ASP.Net MVC. How do I close a jQuery Simplemodal? I've opened it this…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
19
votes
14 answers

jquery simplemodal dynamic height

I'm using the simplemodal popup in jquery, and I would like to set the height of my popup dynamically depending on my content. Currently, it is fixed at 500. If I remove the height property, then it works the first time, but if the content grows,…
Swami
15
votes
5 answers

Simple Modal, jQuery 1.8.0 and IE9

Simple Modal fails with jQuery 1.8.0 and IE9 with the error: SCRIPT438: Object doesn't support property or method 'removeExpression' The following fiddle demonstrates (remember to run with IE9) http://jsfiddle.net/ericjohannsen/ZVEWa/1/ Switching…
Eric J.
  • 147,927
  • 63
  • 340
  • 553
13
votes
6 answers

jQuery simplemodal disable scrolling

I have more than 2000 pixels scrolling content on a page. If the user clicks a div a scrolling content pops up in a simplemodal window. Now my client wants to make the original page non-scrollable while the modal window is up. (Of course the modal…
smds45
  • 131
  • 1
  • 1
  • 4
13
votes
3 answers

How do I get a result from a modal dialog in jQuery

I would like to use an add-in like simple-modal or the dialog add-in in the UI kit. However, how do I use these or any other and get a result back. Basically I want the modal to do some AJAX interaction with the server and return the result for the…
Gabe Anzelini
  • 231
  • 1
  • 3
  • 10
10
votes
4 answers

Remove border from Material UI Modal

I am trying to use the React Material UI Modal but I always get a black border around the modal when it is focused on. I have removed the border when it is out of focus, but if the modal is focused, the border comes back. Any suggestions on how to…
Sri
  • 2,281
  • 2
  • 17
  • 24
6
votes
3 answers

using simplemodal, show loading spinner while content inside iframe loads

Good morning! I am using the great SimpleModal plugin for jQuery from Eric Martin. Currently, I am loading a modal using an iframe to load my requested pages which works as expected. What I would like to implement is a Loading... spinner which…
messedupfir
  • 127
  • 2
  • 3
  • 9
6
votes
1 answer

Modal Form in asp.net mvc RC using jquery

I am new to ajax / jquery and have had difficulty finding a simple sample incorporating the following: ASP.Net MVC RC1 (or 2) jquery modal form I would like the user to be able to click a link/button in a View (Parent) and have a modal form appear…
Jay Walker
  • 4,654
  • 5
  • 47
  • 53
6
votes
3 answers

conflict between SimpleModal and Bootstrap modal

I Have both these plugins included in same page which is causing conflict in-between them. I removed the Bootstrap.min.js and SimpleModal worked fine. I removed jquery.simplemodal.js and Bootstrap modal worked fine. I Tried to invoke bootstrap modal…
5
votes
4 answers

Why choose SimpleModal over jQuery UI Dialog?

New to Javascript/jQuery. I was looking for a good popup solution then I found the jQuery plugin SimpleModal, from Eric Martin, which seemed to be quite popular. I am curious as to why people would choose plugins like SimpleModal over the jQuery UI…
tamakisquare
  • 16,659
  • 26
  • 88
  • 129
5
votes
1 answer

when using SimpleModal and open an Iframe it is calling the src twice

I am using SimpleModal and i am opening an Iframe (using ff) it seems to work ok in ie9 but in ff it is calling the iframe src twice Thanks for any help the code i am calling looks like function addNew(){ var src =…
randy
  • 1,685
  • 3
  • 34
  • 74
5
votes
2 answers

How to use SimpleModal in listView edit action

I want to integrate SimpleModal in My ListView edit action so when the user click edit, the modal popup loaded with data through ajax to edit the form . My simple listview :
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
5
votes
1 answer

Basic Help with SimpleModal and ASP.NET

Integrating SimpleModal with ASP.NET I want to thank Eric for producing SimpleModal and compliment the demos. It looks fantastic.. I only wish I could figure out how to use it.. (it's me, I'm missing some chromosome or something.) Sorry in advance…
asus3000
  • 163
  • 3
  • 12
5
votes
3 answers

SimpleModal confirm before closing dialog

I'm using SimpleModal (http://www.ericmmartin.com/projects/simplemodal/) and I have a form that displays in a dialog. What I want to do is be able to have a confirmation come up each time that the user tries to close the dialog (either by escape or…
user247653
1
2 3
45 46