jQuery UI confirm dialog not returns true/false

前端 未结 5 2004
清歌不尽
清歌不尽 2021-01-06 13:14

I have jQuery UI confirm dialog:

function fnComfirm(title, content) {
    $(\"#dialog:ui-dialog\").dialog(\"destroy\");
    $(\"#dialog-confirm p\").html(con         


        
5条回答
  •  轮回少年
    2021-01-06 13:50

    The returns is in the context of ok and cancel buttons in a nested function you can try call backs:

    function fnComfirm(title, content,onSusses,onCancel) {
        $("#dialog:ui-dialog").dialog("destroy");
        $("#dialog-confirm p").html(content);
        $("#dialog-confirm").dialog({
            title: title,
            resizable: false,
            height: 200,
            width: 486,
            modal: true,
            buttons: {
                "OK": function() {
                    $( this ).dialog("close");
                    onSusses();
                },
                Cancel: function() {
                    $( this ).dialog("close");
                    onCancel();
                }
            }
        });
    }
    

    and call then

    fnComfirm(title,content,function(){alert('Ok')},function(){alert('cancel');}})
    

提交回复
热议问题