Bootstrap modal not closing after form submission

NN796

I believe I will get a solution here, bootstrap modal does not disappear after form submission. I only want to make bootstrap modal disappear after form submission and when again button is clicked (without refreshing the page) form should open, send data and modal should disappears and so on... This is it !

Here is a bootstrap modal:

<div class="modal fade myPopup" id="basicModal" tabindex="-1" role="dialog" 
aria-labelledby="basicModal" aria-hidden="true">
  <div class="modal-dialog" id="modal_dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Add New Board</h4>
      </div>
      <div class="modal-body">
        <form class="create_Category_board" id="myform">
          <input type="text" 
                 id="customInput"
                 class="board_name"
                 name="board[name]"
                 placeholder="Board Name ..." />
          <input type="text"
                 class="board_description"
                 name="board[description]"
                 placeholder="Board Description ..." />
          <input type="hidden"
                 class="board_description"
                 id="myCid"
                 name="board[category_id]" />
          <input type="submit" value="Create Board" class="ShowFormButton"/>
        </form>
      </div>
      <div class="modal-footer">

      </div>
    </div>
  </div>
</div>

My form is bound with backbone JS function:

events: {

    "submit form.create_Category_board": "createCategoryBoard"
  },

  createCategoryBoard: function(event) {
    event.preventDefault();
    var that = this;

    // get form attrs, reset form
    var $form = $(event.target);
    var attrs = $form.serializeJSON();

    $form[0].reset();

    var board = new Kanban.Models.Board();

    // fail if no board name
    if (!attrs.board.name) {
      var $createContainer = $("div.create_board");
      var $nameInput = that.$el.find("input.board_name");

      $createContainer.effect("shake", {
        distance: 9,
        times: 2,
        complete: function() {
          $nameInput.show();
          $nameInput.focus();
        }
      }, 350);
      return false;
    }

    attrs.board.category_id = myid;
    var category = Kanban.categories.get(myid);
    var boards = category.get("assigned_boards");
    // save list
    board.save(attrs.board, {
      success: function(data) {
        board.get("users").add(Kanban.currentUser);

        boards.add(board);

        // keep focus on list input
        that.$el.find("input.board_name").focus();

      }
    });
    $('#basicModal').modal('hide');
  }

As a last line in above function I have tried most popular solution $('#basicModal').modal('hide'); available on web! It makes my modal look like this:

modal

i.e. it not hides the modal, moreover make screen black and change the direction of bootstrap modal from center of screen to little right. May be it is overridden by CSS of JS. But I am not sure.

NN796

I am posting my own answer because if some one needs a quicker help, then may be it is helpful: Just replace: $('#basicModal').modal('hide'); with this line:

$(".modal-header button").click(); which is last line of my JS function. Cheers :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Django bootstrap modal after form submission

From Dev

prevent bootstrap modal window from closing on form submission

From Dev

Bootstrap Form Submission and Modal

From Dev

Closing Bootstrap Modal form after a Successful Ajax Request

From Dev

How to reset the form validations of angularjs after closing the bootstrap modal

From Dev

Focus after closing Bootstrap Modal

From Dev

how to disable modal popup after form submission

From Dev

Bootstrap modal makes scrollbar disappear after closing

From Dev

Set focus to text after closing modal form

From Dev

Bootstrap Modal PHP submission

From Dev

How to show confirmation modal in Flask app after form submission?

From Dev

Not able to close modal pop up window after form submission

From Dev

Closing bootstrap modal

From Dev

Bootstrap checkbox in modal remain checked after closing and reopen again

From Dev

Redirecting after Closing Bootstrap Modal using React-Router

From Dev

Modal Bootstrap is open and closing after being called from a function

From Dev

Bootstrap modal form does not close after submit

From Dev

Show bootstrap popover after submitting form that is in modal

From Dev

Bootstrap dropdown not working after initial ajax form submission

From Dev

Modal Form Submission without refresh

From Dev

emberjs form submission in modal window

From Dev

Calling BS Modal on form submission

From Dev

Closing a Bootstrap modal hangs in Firefox when .form-control inside modal has focus

From Dev

Closing a Bootstrap modal hangs in Firefox when .form-control inside modal has focus

From Dev

How can I unfocus the modal trigger button after closing the modal in bootstrap

From Dev

Closing A Bootstrap Modal Window in Laravel

From Dev

How to avoid closing a modal in bootstrap

From Dev

javascript bootstrap modal - cancel closing

From Dev

which event occurs on a parent form after closing its modal child form in WinForms?

Related Related

  1. 1

    Django bootstrap modal after form submission

  2. 2

    prevent bootstrap modal window from closing on form submission

  3. 3

    Bootstrap Form Submission and Modal

  4. 4

    Closing Bootstrap Modal form after a Successful Ajax Request

  5. 5

    How to reset the form validations of angularjs after closing the bootstrap modal

  6. 6

    Focus after closing Bootstrap Modal

  7. 7

    how to disable modal popup after form submission

  8. 8

    Bootstrap modal makes scrollbar disappear after closing

  9. 9

    Set focus to text after closing modal form

  10. 10

    Bootstrap Modal PHP submission

  11. 11

    How to show confirmation modal in Flask app after form submission?

  12. 12

    Not able to close modal pop up window after form submission

  13. 13

    Closing bootstrap modal

  14. 14

    Bootstrap checkbox in modal remain checked after closing and reopen again

  15. 15

    Redirecting after Closing Bootstrap Modal using React-Router

  16. 16

    Modal Bootstrap is open and closing after being called from a function

  17. 17

    Bootstrap modal form does not close after submit

  18. 18

    Show bootstrap popover after submitting form that is in modal

  19. 19

    Bootstrap dropdown not working after initial ajax form submission

  20. 20

    Modal Form Submission without refresh

  21. 21

    emberjs form submission in modal window

  22. 22

    Calling BS Modal on form submission

  23. 23

    Closing a Bootstrap modal hangs in Firefox when .form-control inside modal has focus

  24. 24

    Closing a Bootstrap modal hangs in Firefox when .form-control inside modal has focus

  25. 25

    How can I unfocus the modal trigger button after closing the modal in bootstrap

  26. 26

    Closing A Bootstrap Modal Window in Laravel

  27. 27

    How to avoid closing a modal in bootstrap

  28. 28

    javascript bootstrap modal - cancel closing

  29. 29

    which event occurs on a parent form after closing its modal child form in WinForms?

HotTag

Archive