Reputation: 9342
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
Reputation: 348
This worked for me:
$("#dialog-modal").on('dialogclose', function (event, ui) {
changeImage()
})
Upvotes: 0
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
Reputation: 15229
Assuming you are using the bootstrap modal library:
$('#modal-dialog').on('hidden', function () {
// do something…
})
Upvotes: 1