Close the Bootstrap modal after registering

Asked

Viewed 1,060 times

3

Colleagues

I have a system from which the user when clicking the link Cadastrar Matéria will open the modal below:

inserir a descrição da imagem aqui

But I would like to click on Save, modal closes automatically. I tried using the code below, modal closes, but the background remains:

$(document).ready(function(){ 
  $('#submit').click(function(ev){
    ev.preventDefault();
    $("#myModal").hide();
    });
});

The background remains:

inserir a descrição da imagem aqui

  • Try $("#myModal").modal("hide"); (http://www.w3schools.com/bootstrap/bootstrap_ref_js_modal.asp)

2 answers

6


subtle:

 $("#myModal").hide();

for:

$("#myModal").modal('hide');

If I’m not mistaken, that’s it

  • 1

    I was just writing this... +1

  • Perfect Cassiano. It worked. I can only accept your answer after 11 minutes, but I’ll come back here to accept it. Thank you!

  • You’re welcome @Fox.11 . Hug

0

I had a similar problem, but in a project where I was using Angularjs.

then when the user clicked on save, it executed the following function:

vm.modalFecha = function(){
    $('#modalpesq').modal('hide');
    $('.modal-backdrop').css('display', 'none');
    $('.ng-scope').removeClass('modal-open');
}

I believe that only by inserting the line below already solve your problem:

$('.modal-backdrop').css('display', 'none');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.