How to dismiss a web modal dialog from bootstrap manually?

aarelovich

I have a small form dialog. the user enters a name, if the name exists or is empty an error is thrown in the dialog box. Other wise the name is added a a database and the dialog should close. The last part is what I don't know how to do it.

The breakdown is as follows:

Here is the code from the dialog (html+bootstrap).

  <div class="modal fade" id="modal_new_project" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title" id="myModalLabel">Nuevo proyecto</h4>
    </div>
      <div class="modal-body">
        <form action="" method="post" name="newprojform" class="form">
          <div class="form-group">
        <label for="projname" class="control-label col-xs-4">Nombre</label>
          <input type="text" class="form-control" id="projname" name="projname">
          <h3><label id="projname_status" class="label label-danger"></label></h3>
          </div>              
          <button type="button" name="verifyproject" class="btn btn-primary" onclick="errorInProyect('apretado')">Crear nuevo proyecto</button>       
        </form>
      </div>
    <div class="modal-footer">        
    </div>
  </div>
</div>
  </div> 

This calls the javascript function:

  <script>
function errorInProyect(err){
    if (document.getElementById("projname").value == ""){
      document.getElementById("projname_status").innerHTML =  "El nombre del proyecto no puede estar vacio";
    }
    else{
    var pname = document.getElementById("projname").value;
    jQuery.ajax({
        type: "POST",
        url: 'addproject.php',
        dataType: 'json',
        data: {functionname: 'check_for_existing_project', args: [pname]},
        success: function (obj) {
              if (obj.error != ""){
                document.getElementById("projname_status").innerHTML = obj.error;
              }
              else{
                //CLOSE DIALOG
              }
            }
    });
    }
}
  </script>

I need to know how to dismiss the dialog in case there were no problems

Flowerking

Try

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

The documentation might help for more varied usages.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Data-Dismiss: How to dismiss bootstrap modal inside function

From Dev

Data-Dismiss: How to dismiss bootstrap modal inside function

From Dev

How to prevent the backdrop of bootstrap modal dialog from covering the whole screen?

From Dev

How to prevent the backdrop of bootstrap modal dialog from covering the whole screen?

From Dev

How to dismiss modal ViewController from right to left?

From Dev

Displaying a bootstrap Modal dialog from Angular Controller

From Dev

Bootstrap modal dialog set attributes from javascript

From Dev

Bootstrap Modal validation displaying on dismiss

From Dev

Bootstrap Modal validation displaying on dismiss

From Dev

How to show a modal dialog using bootstrap

From Dev

How to detect the dismissal of a bootstrap modal dialog in javascript?

From Dev

bootstrap dismiss modal and display another modal

From Dev

How to dismiss dialog when load data from internet in fragment on Android

From Dev

How to dismiss Android Dialog shown on create, from an function

From Dev

How to dismiss all the dialogs from button click of last opened dialog?

From Dev

How to dismiss a viewController pushed from a modalViewController without dismissing the modal?

From Dev

href in modal dialog in bootstrap

From Dev

Validation in bootstrap modal dialog

From Dev

How to clear previously filled in contents from HTML controls of Bootstrap modal dialog?

From Dev

How to get selected item in Bootstrap 3 dynamic dropdown modal dialog from javascript

From Dev

How to dismiss system dialog in Android?

From Dev

How to dismiss system dialog in Android?

From Dev

Xcode - how to dismiss modal UIImageView?

From Dev

How to switch from a bootstrap modal to a angular modal

From Dev

How to switch from a bootstrap modal to a angular modal

From Dev

How to show a modal dialog from a modeless form?

From Dev

AngularJS - How to Create a Modal Dialog from the Controller

From Dev

AngularJS Bootstrap Modal $modalInstance.dismiss is not a function

From Dev

How can i prevent an android dialog from dismiss when user press beside the dialog?

Related Related

  1. 1

    Data-Dismiss: How to dismiss bootstrap modal inside function

  2. 2

    Data-Dismiss: How to dismiss bootstrap modal inside function

  3. 3

    How to prevent the backdrop of bootstrap modal dialog from covering the whole screen?

  4. 4

    How to prevent the backdrop of bootstrap modal dialog from covering the whole screen?

  5. 5

    How to dismiss modal ViewController from right to left?

  6. 6

    Displaying a bootstrap Modal dialog from Angular Controller

  7. 7

    Bootstrap modal dialog set attributes from javascript

  8. 8

    Bootstrap Modal validation displaying on dismiss

  9. 9

    Bootstrap Modal validation displaying on dismiss

  10. 10

    How to show a modal dialog using bootstrap

  11. 11

    How to detect the dismissal of a bootstrap modal dialog in javascript?

  12. 12

    bootstrap dismiss modal and display another modal

  13. 13

    How to dismiss dialog when load data from internet in fragment on Android

  14. 14

    How to dismiss Android Dialog shown on create, from an function

  15. 15

    How to dismiss all the dialogs from button click of last opened dialog?

  16. 16

    How to dismiss a viewController pushed from a modalViewController without dismissing the modal?

  17. 17

    href in modal dialog in bootstrap

  18. 18

    Validation in bootstrap modal dialog

  19. 19

    How to clear previously filled in contents from HTML controls of Bootstrap modal dialog?

  20. 20

    How to get selected item in Bootstrap 3 dynamic dropdown modal dialog from javascript

  21. 21

    How to dismiss system dialog in Android?

  22. 22

    How to dismiss system dialog in Android?

  23. 23

    Xcode - how to dismiss modal UIImageView?

  24. 24

    How to switch from a bootstrap modal to a angular modal

  25. 25

    How to switch from a bootstrap modal to a angular modal

  26. 26

    How to show a modal dialog from a modeless form?

  27. 27

    AngularJS - How to Create a Modal Dialog from the Controller

  28. 28

    AngularJS Bootstrap Modal $modalInstance.dismiss is not a function

  29. 29

    How can i prevent an android dialog from dismiss when user press beside the dialog?

HotTag

Archive