Dialog callbacks ?
Dialog callbacks ?
Hi,
I am using a JQuery UI Dialog box and I am having trouble with
figuring out which button is selected.
It's basically a Yes/No modal dialog to determine whether or not the
user wants to delete a database record.
Question how do I determine whether or not the Yes button is
selected ?
Note : In earlier version of JQuery/UI the code to delete records was
inside the callback function, but I am
having problems with this approach (scope of variables, calling other
functions)
The code is as follows
// general purpose function for confirming record deletions
function confirm_delete_dialog(title,messagetext,urlstr,element){
var confirmed;
var buttons = {};
$('#messagepanel').text('');
$('#panel').html(messagetext);
buttons["Yes"] = function(event) {
// delete_record(urlstr,element); does not work anymore,
passes the old values of urlstr and element
$(this).dialog("close");
return(true);
}
buttons["No"] = function(event) {
$(this).dialog("close");
return(false);
}
$('#panel').dialog({
modal: true,
draggable: false,
height:180,
overlay:{
opacity: 0.5,
background: "black"
},
title: title,
buttons: buttons
});
$('#panel').dialog('open');
return(false);
}