jQuery UI 对话框模式仅使用类选择器打开一次

jquery ui dialog modal only opens once using class selector

本文关键字:一次 选择器 对话框 UI 模式 jQuery      更新时间:2023-09-26
        $(".groomed").click(function() {
            var modal = $(".dash-modal", this).dialog({
                    height:400,
                    width:800,
                    modal:true,
                    autoOpen: false,
                    Cancel: function() {
                            $(".dash-modal", this).dialog("destroy");
                    }
            });
            console.log(modal);
            modal.dialog('open');
    });

我已经扔掉了所有的堆栈溢出,它们都处理一个id选择器,我需要它来与类选择器一起工作。上面包含代码。

控制台会在第一次单击时记录以下内容:

[div#ui-id-2.dash-modal info ui-dialog-content ui-widget-content, prevObject: e.fn.e.init[1], context: tr.groomed, selector: ".dash-modal", constructor: function, init: function...]

第二个:[prevObject: e.fn.e.init[1], context: tr.groomed, selector: ".dash-modal", constructor: function, init: function...]

所以看起来整个功能在模式关闭后被删除,api说使用destroy,我已经尝试过关闭:和取消:

请帮忙,谢谢!

  Cancel: function() {
                            $(".dash-modal", this).dialog("destroy");
                    }

这样就可以破坏对话框

关闭对话框以根据您的要求使用

 Cancel: function() {
                            $(".dash-modal", this).dialog("close");
                    }

引用对话框关闭对话框销毁