关闭Bootstrap Modal在表单上提交 [英] Close Bootstrap Modal On form Submit

查看:102
本文介绍了关闭Bootstrap Modal在表单上提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含表单的Bootstrap Modal。 Modal还包含,提交和取消按钮。现在根据我的要求,在提交按钮单击模态,表单正在成功提交但模态未关闭..这是我的HTML ..

I have a Bootstrap Modal which contains form . The Modal also Contains , Submit and Cancel Button. Now as per my requirement , on Submit Button Click of the Modal , Form is Submitting Successfully but Modal is Not getting closed..Here is my HTML..

<div class="modal fade" id="StudentModal" tabindex="-1" role="dialog" aria-labelledby="StudentModalLabel" aria-hidden="true" data-backdrop="static">
   <div class="modal-dialog">
      <div class="modal-content">
         <form action="~/GetStudent" class="form-horizontal" role="form" method="post" id="frmStudent">
            <div class="modal-footer">
               <div class="pull-right">
                  <button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-ok"></i> Save</button>
                  <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i> Close</button>
               </div>
            </div>
         </form>
      </div>
   </div>

怎么做..请帮助我..谢谢..

How to do it ..Please help me ..Thanks..

推荐答案

使用该代码

 $('#button').submit(function(e) {
    e.preventDefault();
    // Coding
    $('#IDModal').modal('toggle'); //or  $('#IDModal').modal('hide');
    return false;
});

这篇关于关闭Bootstrap Modal在表单上提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆