bootstrap jquery show.bs.modal event won't fire

m4rlo picture m4rlo · Oct 9, 2013 · Viewed 150.9k times · Source

i'm using the modal example from the bootstrap 3 docs. the modal works. however i need to access the show.bs.modal event when it fires. for now i'm just trying:

$('#myModal').on('show.bs.modal', function () {
   alert('hi')
})

Nothing happens, the event does not fire. What am I doing wrong??? This doesn't make sense to me.

Answer

Ali picture Ali · Feb 21, 2016

use this:

$(document).on('show.bs.modal','#myModal', function () {
  alert('hi');
})