$(“UI的对话框的标题栏关闭”)触发(‘点击’)。进入无限循环

时间:2013-04-29 07:39:38

标签: jquery

$.post(url, data, function(resp) {
    if (resp.error) {
        ...
    }
    else {
        $(".ui-dialog-titlebar-close").trigger('click');
    }
},"json");
}

我需要在else循环中关闭对话框,但是:

$('#customAssignmentDialog').dialog('close');

不关闭对话框,所以我尝试了:

$(".ui-dialog-titlebar-close").trigger('click');

但它进入无限循环。任何想法?强调文字

2 个答案:

答案 0 :(得分:0)

得到了......

$('.ui-dialog-titlebar-close:visible').click()

答案 1 :(得分:0)

这是一个有效的例子,希望这会有所帮助:

<div id="dialog-message" title="Close Example">
    <span class="dialog-descr">
        Click Create to close the widget.
    </span>           
</div>  

<script>
    $(document).ready(function(){

        var closeWidget = function(){
            $("#dialog-message").dialog('close');
        }

        $("#dialog-message").dialog({
            autoOpen: false,
            modal: true,
            draggable: false,
            resizable: false,
            position: {my: "center top", at: "center top"},
            show: 'blind',
            hide: 'blind',
            width: 400,
            dialogClass: 'ui-dialog-osx',
            buttons: {
                "Create": closeWidget,
                "Annulla": function() {
                    $(this).dialog("close");
                }
            }
        });         

    });
</script>