Intro
Jquery-popup-box is a simple jQuery plugin that can be used to replace build in popups. This plugin was written because:
- it will not interrupt and stop script execution when popups are used
- it provides an elegant way for follow up code depending on user choices
- popups are easy way to explain and understand jQuery Deffered objects
jQuery Deferred
jQuery introduced Deffered objects in 1.5. They are easy way to stash functions that will be executed after something else eventually happen.
Since this plugin uses jQuery Deferred objects, showing popup window will not stop executing script. Also, you can provide callback that will be executed if user cancels and close the window (in fail method) and the callback for execution if she/he clicks OK.
Dependencies
- jQuery
- jQuery UI
Demo
$("#alert").click(function () { $.alert("This is simple alert message", "Title"); });
$("#prompt").click(function () { $.prompt("Enter your name", "John") // execute this if user clicks ok .done(function (name) { $.alert("Hi " + name, "Greeting"); }) // execute this if user cancels .fail(function () { $.alert("You didn't want to input your name", "See you next time"); }); });
$("#confirm").click(function () { $.confirm("Confirm this action", "Please make choice") .done(function () { $.alert("You said OK", "Yupiii"); }) .fail(function () { $.alert("You canceled!", "Noooo"); }) });