visma-meglerfront/sweet-modal

Programmatically close

Closed this issue · 3 comments

wsnnn commented

Hello!
How can I close the already opened sweet-modal window programmatically from another sweet-modal window?
I made a variable sm = $.sweetModal() and the function OnOpen I call another sweetModal window. In it in the function OnClose call sm.close(), the parent window is closed, but will remain overlay, which blocks html.

Maybe there is some way to close all the windows?

var sm = $.sweetModal({
            //parent
            onOpen: function () {
                    //Some ajax actions, callback open a window
                    $.sweetModal({
                     //child
                        onClose: function () {
                            //close parent
                            sm.close();
                        }
                    });
            }
        });

I've the same problem, so i've tested this and it works:
$(".sweet-modal-close-link").click();
Thanks

@guillaume23 While this technically works it is only considered a workaround. I'm investigating for a real solution.

Fixed in edc7e51, released in v1.3.3