I'm trying to use the jQuery UI Dialog to display a confirmation prior to executing the action...in this case navigating to the selected link....but in another case, I might like to use AJAX delete.
I thought I could pass the action as parameter of the custom_confirm function:
$("a.edit").click(function(e){
e.preventDefault();
custom_confirm('Please Note:',
function(){
location.href = $(this).attr('href');
}
);
});
function custom_confirm(prompt, action, title){
if (title === undefined) title = "Are you sure?";
if ($("#confirm").length == 0){
$("#main div.inner").append('<div id="confirm" title="' + title + '">' + prompt + '</div>');
$("#confirm").dialog({buttons: {'Proceed': function(){ $(this).dialog('close'); action; }, Cancel: function(){ $(this).dialog('close'); }}});
}
else {
$("#confirm").html(prompt);
$("#confirm").dialog('open');
}
}
It's not working. Is there another way to accomplish this?