jQuery Popup.js Examples
Basic Popup
Creating a new window with Popup is easy! Just call $.popup.create("popup_id"). If an element already exists with the id "popup_id", it will be used to create the window. Otherwise, Popup will create the element for you.




Dynamic Popup
When no element exists in the DOM with the id you send to the popup create method, it will be created for you and appended to the body by default. You can set the content by either setting the content option in the options hash when creating the popup, or by manually calling the popup's content method.

Content:




AJAX Popup
You can also load popup content by using AJAX. You can do this by either setting the "url" option when creating the popup, or by calling the popup's load method.




Centered Popup
Popup features full support for centering. In order to enable centering, you can set the "center" option when creating the popup, or later by calling the popup's center_options method. The value you set it to should be a space separated string that specifies the centering modes you wish to enable. Here is a list of all the valid centering modes:


Options:




Templates
Manually entering buttons to let users close popup windows gets a little old after a while doesn't it? That's why Popup has full support for templates! Templates can be used to define a snippet of HTML that will wrap the content of the popup whenever it is loaded or changed. You can set the template either by setting the template option of the popup when it is being created, or by calling the template method after it has been created. The value you set can be either a jQuery object, a valid jQuery selector string, or a string of HTML (but only if it starts with a valid HTML tag). The template can include any content you like, but in general it is probably most useful to provide menu buttons and/or navigation features. The template should contain at least one empty div with the class "popup_content", in which Popup will place the actual content when it is set.




Backgrounds
Popup supports backgrounds in order to let you create modal style popups. Backgrounds will fill the area of the parent element with an element that will block the user from interacting with the parent until the popup is closed. Backgrounds can be set just like templates, by setting the background option when creating the popup, or by calling the popup's background method. Valid values that can be used to set the background incude a jQuery selector, a valid jQuery selector string, an HTML string that starts with a valid HTML tag, or the value true, which will set the background to an empty element with the class "popup_background". The default background also includes the "popup_close" class, so it will trigger a close event when it is clicked, but user created backgrounds must make sure they manually include the class "popup_close" if they wish to emulate this behavior.




Loading Messages
Popup allows you to define a loading message that will be displayed while waiting for AJAX content to be loaded. As with backgrounds and templates, the content can be set with the "loading" option when creating the popup, or by calling the popup's loading method. Valid values that can be used to set the loading message incude a jQuery selector, a valid jQuery selector string, an HTML string that starts with a valid HTML tag, or the value true, which will set the loading message to an empty element with the class "popup_loading". The default value for this setting is null, which will leave the current popup content displayed until the new content is ready.