BillPull BillPull - 1 year ago 120
Javascript Question

Bind a function to Twitter Bootstrap Modal Close

I am using the Twitter Bootstrap lib on a new project and I want for part of the page to refresh and retrieve the latest json data on modal close. I dont see this anywhere in the documentation can someone point it out to me or suggest a solution.

Two problems with using the documented methods

$('#my-modal').bind('hide', function () {
// do something ...

I attach a "hide" class to the modal already so it does not display on page load so that would load twice

even if I remove the hide class and set the element id to "display:none" and add "console.log("THE MODAL CLOSED");" to the function above when I hit close nothing happens.

Answer Source

Bootstrap 3

$('#myModal').on('', function () {
    // do something…
}) -> Events

Bootstrap 2.3.2

$('#myModal').on('hidden', function () {
    // do something…
}) -> Events

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download