Jobin Jobin - 6 months ago 9
jQuery Question

How to handle the close event of Bootstrap popup

In my mvc application I have used one bootstrap popup, I need to check whether any changes are made in textboxes in this popup before closing this window, and give an option to save this before closing. How can I handle the close event of bootstrap popup window?
I have tried

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


It will only fire after the close event.

Answer

Use the hide.bs.modal event..

$('#myModal').on('hide.bs.modal', function (e) {
    //do something..
})

Example: http://www.codeply.com/go/wTys5mP4nw