Skip to content Skip to sidebar Skip to footer

How To Delay Display Of Bootstrap 3 Modal After Click

I'm trying to delay the display of a Bootstrap modal after the user has clicked on a trigger button:

http://jsfiddle.net/mblase75/H6UM4/


Solution 2:

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/


Solution 3:

window.setTimeout(function() {
   $('#myModal').modal('show');
}, 5000)

For demo I used 5000 mini seconds. You can used it as per your need...


Solution 4:

If any of those above method does't work, give this method a try. It will work perfectly.

$(window).ready(function() {
   setTimeout(function(){
       $('#myModal').modal('show');
   }, 2000);
});

Post a Comment for "How To Delay Display Of Bootstrap 3 Modal After Click"