[英]How do I use a jQueryUI Dialog for confirmation?
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. 我正在尝试使用jQueryUI对话框在数据库更新之前获得用户确认,但我正在努力看看如何判断用户在对话框上的选择,因为我可以找到所有样本,两个按钮都关闭对话框,没有所选按钮的持久性。 Eg from the jQueryUI sample and docs:
例如,来自jQueryUI示例和文档:
buttons: {
'Deactivate the campaign': function () {
$(this).dialog('close');
},
Cancel: function () {
$(this).dialog("close");
}
}
Your calling the same function ( $(this).dialog('close'); ) for both buttons. 你为两个按钮调用相同的函数($(this).dialog('close');)。 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");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.