jQuery UI confirm dialog not returns true/false

前端 未结 5 2009
清歌不尽
清歌不尽 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 14:01

    I don't know JS too well, but my guess is that the return false is returning within the nested function?! What you would want to do is this;

    function fnComfirm(title, content) {
    var returnVar;
    $("#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");
                returnVar = true;
            },
            Cancel: function() {
                $( this ).dialog("close");
                returnVar = false;
            }
        }
    });
    return returnVar;
    }
    

    Like I said, I'm not an expert in Javascript, but this is what I think is the problem :)

提交回复
热议问题