Created
July 25, 2011 03:33
-
-
Save adatta02/1103518 to your computer and use it in GitHub Desktop.
quick n dirty jQuery UI confirm() dialogs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.confirm = function(options){ | |
var opts = jQuery.extend( { message: "", ok: function(){}, cancel: function(){ } }, options ); | |
jQuery("<div class=\"span-10\"> | |
<div class=\"ui-confirm-message\">" | |
+ opts.message + "<img class=\"loader\" style=\"padding-left: 10px\" src=\"/images/loader.gif">\"</div></div>").dialog({ | |
autoOpen: true, | |
modal: true, | |
autoOpen: false, | |
resizable: false, | |
draggable: false, | |
title: "", | |
width: "400px", | |
buttons: { | |
"Cancel": function(){ | |
opts.cancel.call( this ); | |
}, | |
"Ok": function(){ | |
opts.ok.call( this ); | |
} | |
} | |
}).dialog("open"); | |
}; | |
// use it | |
jQuery.confirm( { | |
"message": "Are you sure?", | |
"ok": function( ){ | |
$(this).find(".loader:first").show(); | |
// do stuff | |
$(this).dialog("close"); | |
}, | |
"cancel": function( ){ | |
$(this).dialog("close"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment