简体   繁体   English

如何使用jQueryUI对话框进行确认?

[英]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.

相关问题 如何让jQueryUI的'对话'小部件使用`ui-state-error`样式? - How do I get jQueryUI's 'dialog' widget to use the `ui-state-error` styles? 使用 jQueryUI 对话框确认时如何停用“输入键” - How to Deactivate "Enter Key" when using jQueryUI Dialog Confirmation 如何使用 jqueryui 对话框按钮提交表单, - How do i submit a form with jqueryui dialog button, 如何使用Jquery ui对话框确认进行gridview链接按钮? - How can i use Jquery ui dialog confirmation for gridview linkbutton? 表单提交上的jQueryUI模式确认对话框 - jQueryUI Modal confirmation dialog on form submission 使用jQueryUI Dialog,我如何获得打开对话框的元素? - Using jQueryUI Dialog, how can I get the element that opened the dialog? 如何使用jqueryui在关闭对话框按钮周围摆脱这个蓝色光环? - How do I get rid of this blue halo around the close dialog button with jqueryui? 当长时间在主线程中执行某些操作时,如何让jQueryUI显示对话框? - How do I get jQueryUI to display a dialog when something long running is executing in the main thread? Django/JqueryUI 对话框 - 如何将 Django 与 JqueryUI 对话框集成? - Django/JqueryUI dialog box - How can I integreate Django with JqueryUI dialog box? jQueryUI-如何使用确认对话框(如本地JS Confirm())? - jqueryUI - how to use a confirm dialog like a native JS confirm()?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM