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
-1
votes
1 answer

Load an Embedded You Tube or Vimeo Video in Simple Modal

The website is a little tricky to use. But I am looking to simply load and embedded vimeo video into the modal without using an iframe tag. I know this is possible but haven't seen too many examples of this. Any info will help. Thanks in advance.
-1
votes
1 answer

jQuery simplemodal "TypeError: Cannot call method 'init' of undefined"

I'm using jQuery 1.9.1 and the latest version of simple-modal jQuery plugin. I'm trying to figure what the init function of jQuery is. Maybe I'm thinking this is a conflict with another library. My JavaScript: $(document).ready(function(){ …
Jack Pilowsky
  • 2,275
  • 5
  • 28
  • 38
-1
votes
1 answer

Can simplemodal confirm hold the function?

Can simplemodal confirm hold the function? Like alert(),the codes after the alert() will not be runned before you click it . I tried , but it doesn't work like this. (My English is poor , so ...)
olivetree123
  • 173
  • 3
  • 13
-1
votes
1 answer

Simplemodal popup display once per session?

I am new to javascript and jQuery. I am using SimpleModal basic to display a popup onload when a user visits my site. It's working great, but each time visitors go to homepage, the popup displays. For example: Visitor A goes to my homepage, the…
Tony Nguyen
  • 1
  • 1
  • 1
-1
votes
1 answer

Modal dialog is not working

In this below code i want to display data in modal window .My aim is to display the searched data in modal dialog .Actual result is they are displaying above the form not in modal dialog.I have tried some steps but i cant able to produce the…
-1
votes
2 answers

How do I invoke a SimpleModal OSX dialog on page load?

I was wondering if there is a way to invoke the SimpleModal OSX dialog box on page load? I tried open jquery modal dialog on page load but wasn't able to make it happen. Currently, the dialog is invoked on clicking a button / link. I would like to…
Priyank Sharma
-1
votes
2 answers

SimpleModal Foreach Loop Dynamic Content

How would you use simplemodal within a foreach loop so that it does not repeat the same information? Example: foreach($ret as $v) {
Justin Lucas
  • 319
  • 2
  • 18
-2
votes
2 answers

Create simple CSS modal window

The goal is to create a simple and CSS-only modal window (popup), when the user clicks a link. With no dependencies or any kind of script, and with as less code as possible.
NDi
  • 184
  • 1
  • 2
  • 17
-2
votes
1 answer

how to add caption and link to image gallery modal?

I am trying to customize a html template. which is https://html5up.net/ethereal it has a gallery with modal. i want to add a simple link and some text in that modal. but i am unable to do so. can any one please help me. Thank You
smehsan
  • 243
  • 1
  • 10
-3
votes
2 answers

PHP code not connecting with html

I'm having a very difficult time getting my PHP and HTML to work together on an email form. This is a website I've adopted and I'm not sure what I'm missing. I'm basically building a form within a modal so users have to register their email before…
-3
votes
2 answers

How to write this from javascript to JQuery

Simple question I need these few lines of javascript in jquery. Just trying to close a modal when I select outside of it. Thank you. // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if…
Matt
  • 137
  • 2
  • 14
-4
votes
1 answer

How to close modal

How can I stop video when modal is closed? breeze.customertests.com/#video-modal The problem I'm having with this is when I play the video and exit the screen while it is being played, the video continues to play in the background. If I click on the…
1 2 3
45
46