I am using JQuery's $.dialog(), where I open a dialog with OK and Cancel buttons.

我正在使用JQuery的$ .dialog(),在那里我打开一个带有OK和Cancel按钮的对话框。

I would have expected that when the dialog opens, the code stops, and would first continue, when the user had selected OK or Cancel.

我希望当对话框打开时,代码会停止,并在用户选择“确定”或“取消”时首先继续。

Here is my complete source code http://pastebin.com/uw7bvtn7

这是我的完整源代码http://pastebin.com/uw7bvtn7

The section where I have the problem is at line 127-151.

我遇到问题的部分是第127-151行。

$("#dialog:ui-dialog").dialog("destroy");

$("#dialog-confirm").dialog({
    resizable: false,
    height: 600,
    modal: true,
    open: function() {
    $(this).children('div.dialog-text').replaceWith("<h3><b>Users</b></h3>" + makeDialogTable(users) + "<h3><b>Owners</b></h3>" + makeDialogTable(owners));
    },

    buttons: {
    "Okay": function() {
        $(this).dialog("close");
    },

    Cancel: function() {
        is_okay = 0;
        $(this).dialog("close");
    }
    } // buttons

}); // dialog


alert(is_okay);

What the code does right now is to first show the dialog and then the alert(is_okay) on top.

代码现在做的是首先显示对话框,然后在顶部显示警报(is_okay)。

What I would like is that the code first continues when the user have pressed OK or Cancel.

我想要的是当用户按下OK或Cancel时代码首先继续。

How could that be done?

怎么可能这样呢?

9 个解决方案

#1


3

You can put your additional code in the "Okay" and "Cancel" button functions. For example:

您可以将其他代码放在“Okay”和“Cancel”按钮功能中。例如:

"Okay": function() {
    $(this).dialog("close");
    alert(is_okay);
},

更多相关文章

  1. 想要改进我的jQuery代码,做我想要的,太丑了,IMO
  2. JQuery的一些基本功能代码(CH1&2)
  3. 如何在angularjs代码中单元测试jquery元素
  4. jquery常用代码片段
  5. bootstrap,模态对话框,shown.bs.modal事件不会触发
  6. Webhoster插入了一个javascript,它会阻止我的代码如何删除它?
  7. 可以直接拿来用的15个jQuery代码片段
  8. 当AJAX响应来自PHP文件时,如何显示以消息为中心的加载器图像&防止
  9. 为什么使用observe_field代码不能使用JQuery模型对话框?

随机推荐

  1. 使用ListView应该注意的地方
  2. android中读取短信
  3. Android Third Party Libraries and SDK'
  4. 去掉非首次开机的优化过程都会有'Android
  5. Android LinearLayout Why Gravity Not W
  6. Android腾讯微薄客户端
  7. LayoutInflater.inflate()方法的介绍
  8. Android Dev Intro - GLSurfaceView.Requ
  9. 获取android webkit 源码
  10. Android(Java):Android ListView checkbo