Lar*_*ara 4 html javascript forms jquery twitter-bootstrap
我有一个包含表格的Bootstrap Modal.Modal还包含提交和取消按钮.取消按钮工作正常,它正在成功关闭模态.现在按照我对提交按钮的要求,通过将用户输入传递给Web服务来单击模板正在成功提交的模式,但Modal没有关闭.此外,我只需要在"提交"按钮单击事件上重新加载页面.这是我的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>
Run Code Online (Sandbox Code Playgroud)
我尝试了以下关闭模态的方法..
$('#frmStudent').submit(function() {
$('#StudentModal').modal('hide');
return false;
});
Run Code Online (Sandbox Code Playgroud)
根据我的要求,我需要关闭提交事件上的模态,并在从Web服务返回后重新加载页面.我怎么能用Jquery做到这一点?
注意:我不应该在这里使用Ajax Call ..我只需要从表单操作提交表单
这不起作用:
<form onsubmit="window.location.reload();">
Run Code Online (Sandbox Code Playgroud)
但这可以完成这项工作:
<form onsubmit="setTimeout(function(){window.location.reload();},10)">
Run Code Online (Sandbox Code Playgroud)
所以浏览器有足够的时间提交表单然后重新加载页面;-)
如果您希望在提交表单时重新加载页面,请使用onsubmit
事件处理程序:
document.getElementById("frmStudent").onsubmit = function(){
location.reload(true);
}
Run Code Online (Sandbox Code Playgroud)
此代码应重新加载页面、提交表单并关闭模式。
归档时间: |
|
查看次数: |
28098 次 |
最近记录: |