-
-
Save agileminds1997/9f4ae811fbcdee56a61c762b4718f463 to your computer and use it in GitHub Desktop.
Bootstrap Modal, ajax submit, and close on submit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ | |
| $('#myFormSubmit').click(function(e){ | |
| e.preventDefault(); | |
| alert($('#myField').val()); | |
| $('#myModal').modal('hide') | |
| /* | |
| $.post('http://path/to/post', | |
| $('#myForm').serialize(), | |
| function(data, status, xhr){ | |
| // do something here with response; | |
| }); | |
| */ | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a> | |
| <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> | |
| <div class="modal-header"> | |
| <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
| <h3 id="myModalLabel">Modal header</h3> | |
| </div> | |
| <div class="modal-body"> | |
| <form id="myForm" method="post"> | |
| <input value="hello" id="myField" type="hidden"> | |
| </form> | |
| </div> | |
| <div class="modal-footer"> | |
| <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> | |
| <button class="btn btn-primary" id="myFormSubmit" type="submit">Submit</button> | |
| </div> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment