简体   繁体   中英

jquery ui dialog modal only opens once using class selector

        $(".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');
    });

I have gone threw all of the stack overflows and they all deal with a id selector and I need this to work with a class selector. Code is included above.

The console logs the following for the first click:

[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…]

And this for the second: [prevObject: e.fn.e.init[1], context: tr.groomed, selector: ".dash-modal", constructor: function, init: function…]

So it looks like the entire functionality is being removed after the modal is closed, the api says to use destroy, I've tried that with both close: and cancel:

Please help, thanks!

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

by this you destroy the dialog box

close dialog box to use according to your requirement

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

reference dialog close and dialog destroy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM