I\'m trying to delay the display of a Bootstrap modal after the user has clicked on a trigger button:
Use .on()
to hook into the event:
var isFirstShowCall = false;
$('#myModal').on('show.bs.modal', function (e) {
isFirstShowCall = !isFirstShowCall; // Prevents an endless recursive call
if(isFirstShowCall) {
e.preventDefault(); // Prevent immediate opening
window.setTimeout(function(){
$('#myModal').modal('show');
}, 3000)
}
});
http://jsfiddle.net/G9XeA/