Bronzato
Bronzato

Reputation: 9342

Doing some things when my jQuery dialog is hidden

I have a jquery dialog on my page. When I don't need my dialog anymore, I "hide" it like this:

$('#modal-dialog').modal('hide');

My question: how can I bind an event on the 'hiding' (not really closing...) of the dialog to do some things.

I already this:

$('#modal-dialog').bind('dialogclose', function (event) {
    // do something here
});

But it doesn't work.

Thanks for your help.

Upvotes: 0

Views: 130

Answers (3)

SingleStepper
SingleStepper

Reputation: 348

This worked for me:

$("#dialog-modal").on('dialogclose', function (event, ui) {
        changeImage()
    })

Upvotes: 0

Stuart Nelson
Stuart Nelson

Reputation: 4202

Depending on how your modal is being hidden (and what event/s you want) you could just string what you want after the hide. If your hide is instant then you could just add more methods: $('#modal-dialog').modal('hide').append("<p>append some text</p>"); Otherwise I would recommend just making a little modal plugin to call the window, and then use $("#modal-container").hide(function(){ //events events events });

Upvotes: 0

mash
mash

Reputation: 15229

Assuming you are using the bootstrap modal library:

$('#modal-dialog').on('hidden', function () {
  // do something…
})

Upvotes: 1

Related Questions