Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade out bootstrap modal using jquery/css

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);
});

Fiddle

like image 687
Fasna Avatar asked Jan 10 '16 03:01

Fasna


2 Answers

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);

 });
like image 104
Fasna Avatar answered Nov 10 '22 00:11

Fasna


Use this code.

$('.save').on('click', function(){
   $('#div_dbReadMany').delay(1000).fadeOut('slow');
   setTimeout(function() {
       $("#div_dbReadMany").modal('hide');
   }, 1500);
});

DEMO

like image 32
Jakir Hossain Avatar answered Nov 09 '22 23:11

Jakir Hossain