Reputation: 576
I have a form inside a bootstrap modal. I awake it using jQuery $(modalId).modal('show');
I don't want it to be fade in. So, I didn't add 'fade' class to my modal. upon submitting the form in modal. I want to fade out the modal.
$(modalId).modal('hide');
I used the above code segment to hide the modal, it works. But, the modal goes out very quickly. I want it to fade out for a few seconds. How can I achieve it?
My code:
$('.save').on('click', function(){
setTimeout(function(){
$('#div_dbReadMany').modal("hide");
}, 1500);
});
Upvotes: 10
Views: 23629
Reputation: 2517
Use this code.
$('.save').on('click', function(){
$('#div_dbReadMany').delay(1000).fadeOut('slow');
setTimeout(function() {
$("#div_dbReadMany").modal('hide');
}, 1500);
});
Upvotes: 4
Reputation: 576
I found the solution by adding a delay to fadeout the modal and increased the time out on
$(modalId).modal('hide');
Code is here:
$('.save').on('click', function(){
$('#div_dbReadMany').delay(1000).fadeOut(450);
setTimeout(function(){
$('#div_dbReadMany').modal("hide");
}, 1500);
});
Upvotes: 5