Skip to content

Instantly share code, notes, and snippets.

@adatta02
Created July 25, 2011 03:33
Show Gist options
  • Save adatta02/1103518 to your computer and use it in GitHub Desktop.
Save adatta02/1103518 to your computer and use it in GitHub Desktop.
quick n dirty jQuery UI confirm() dialogs
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