Close Bootstrap modal on form submit

后端 未结 13 1479
盖世英雄少女心
盖世英雄少女心 2020-12-08 07:08

I have a Bootstrap modal dialog which contains a form. The modal dialog contains a submit and a cancel button. Now on submit button click the form is submitted

13条回答
  •  佛祖请我去吃肉
    2020-12-08 07:39

    Neither adding data-dismiss="modal" nor using $("#modal").modal("hide") in javascript worked for me. Sure they closed the modal but the ajax request is not sent either.

    Instead, I rendered the partial containing the modals again after ajax is successful (I'm using ruby on rails). I also had to remove "modal-open" class from the body tag too. This basically resets the modals. I think something similar, with a callback upon successful ajax request to remove and add back the modals should work in other framework too.

提交回复
热议问题