Skip to content

Instantly share code, notes, and snippets.

@adatta02
Created February 9, 2013 00:29
Show Gist options
  • Save adatta02/4743180 to your computer and use it in GitHub Desktop.
Save adatta02/4743180 to your computer and use it in GitHub Desktop.
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