bootstrap jquery show.bs.modal event won't fire
Solution 1:
use this:
$(document).on('show.bs.modal','#myModal', function () {
alert('hi');
})
Solution 2:
Make sure you put your on('shown.bs.modal')
before instantiating the modal to pop up
$("#myModal").on("shown.bs.modal", function () {
alert('Hi');
});
$("#myModal").modal('show'); //This can also be $("#myModal").modal({ show: true });
or
$("#myModal").on("shown.bs.modal", function () {
alert('Hi');
}).modal('show');
To focus on a field, it is better to use the shown.bs.modal
in stead of show.bs.modal
but maybe for other reasons you want to hide something the the background or set something right before the modal starts showing, use the show.bs.modal
function.