I'm trying to use the jQueryUI Dialog to get user confirmation before a database update, but I'm battling to see how I can tell what the user's choice on the dialog is, as all in samples I can find, both buttons just close the dialog, with no persistence of the chosen button. E.g. from the jQueryUI sample and docs:
buttons: {
'Deactivate the campaign': function () {
$(this).dialog('close');
},
Cancel: function () {
$(this).dialog("close");
}
}
Your calling the same function ( $(this).dialog('close'); ) for both buttons. You need to do somehting more than just close the dialog. You can update a hidden span to pass which button was clicked or just call the DB update from there.
buttons: {
'Deactivate the campaign': function () {
//pass the value using a hidden span
$('#myHiddenControl').val('True');
//or just call the db update
$.ajax({/* db call code ommited*/});
$(this).dialog('close');
},
Cancel: function () {
//pass the value using a hidden span
$('#myHiddenControl').val('False');
$(this).dialog("close");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With