jQuery确认框可暂停脚本执行 [英] jQuery confirm box that pauses script execution

查看:91
本文介绍了jQuery确认框可暂停脚本执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找替代标准对话框的jquery/nice. jQUery UI有一个不错的界面,但它不会像确认()那样暂停脚本执行以等待响应.下面的演示应该显示两个div,这些div显示前面的确认框的选择,但是jquery对话框不会导致脚本等待.

I'm looking for a jquery/nice looking alternative to the standard dialog box. jQUery UI has a nice one, but it doesn't pause script execution to wait for the response like confirm() does. The demo below is supposed to display two divs that display the choice of the preceding confirm box, but the jquery dialog box doesn't cause the script to wait.

http://jsfiddle.net/EvilAmarant7x/r7Ur5/

我特别需要使脚本暂停的内容.

I specifically need something that causes the script to pause.

谢谢

推荐答案

您以错误的方式使用对话框

Your using the dialog in the wrong way

您应该这样做

 $("#dialog-confirm").dialog({
resizable: false,
height: 140,
modal: true,
buttons: {
    Proceed: function() {
          call_true_function();
        $(this).dialog("close");
    },
    Cancel: function() {
        call_false_function()
        $(this).dialog("close");
    }
}
});

或类似的东西

**编辑**

是这样的吗?

count = 0;
$("#dialog-confirm").dialog({
resizable: false,
height: 140,
modal: true,
buttons: {
    Proceed: function() {
          proceed();
        $(this).dialog("close");
    },
    Cancel: function() {
        $(this).dialog("close");
    }
}
});

function proceed(){
    if (count != 10){
        $("#dialog-confirm").dialog('open');    
    }else{
        $('body').append("<div>Yes was selected " + count + " times!</div>");
    }
}

这篇关于jQuery确认框可暂停脚本执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆