I have created a modal popup using the modal UI component. See below:

    ) {
        var options = {
            type: 'popup',
            responsive: true,
            innerScroll: false,
            title: 'Modal Title Goes Here',
            buttons: [{
                text: $.mage.__('Continue'),
                click: function () {

        var popup = modal(options, $('#modal'));


Is there any way that you can detect when the user closes the modal and trigger a function once this event fires?


1 Answer 1


You can use below code to get your functionality done when modal close.

    //your code

You can see the "action-close" class on close(x) button.

Hope it helps :)

  • Im not sure this would work because this would only trigger if you click on the defined element. I need to trigger a function when the modal is closed as you can close the modal in many different ways e.g. click the close button, click the X button, click outside the modal popup window. Aug 17, 2017 at 16:18
  • So in that case you should follow below thread. - magento.stackexchange.com/questions/174782/… ... thanks Aug 17, 2017 at 16:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.