2

I am trying to execute some jQuery code after a Bootstrap modal is closed on my page, I have the id of the modal in my jQuery and everything. I'd like to use a jQuery function of some sort, as opposed to a conditional if-statement. This is the modal which I have open, how would I run some jQuery after it's closed (The animation should be complete and everything)?

<div id="part_number-modal" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="part_number-modal" aria-hidden="false" style="display: block;">
<!-- the rest of the modal HTML is in here -->
</div>
Th4t Guy
  • 1,442
  • 3
  • 16
  • 28
Tigerman55
  • 233
  • 10
  • 20

2 Answers2

10

You can use the hidden event handler

This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).

$('#part_number-modal').on('hidden.bs.modal', function (e) {
  // do something...
})
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
3

Have you checked the documentation?

$('#part_number-modal').on('hidden.bs.modal', function (e) {
  // do something after modal is hidden...
})
Turnip
  • 35,836
  • 15
  • 89
  • 111