Viv*_*P V 6 ajax asp.net-mvc twitter-bootstrap-3
我的模态表单成功发出了Ajax请求.收到的数据显示在后台.调用模式是通过数据-*完成属性作为自举的例子显示在这里.但这种模式并没有被解雇.我试着补充一下
OnSuccess = "$('#searchForm').modal('hide');"
Run Code Online (Sandbox Code Playgroud)
到我的Ajax.BeginForm.但是这并没有消除模态在背景上施放的淡化效果.
我的观点是:
<div class="modal fade" id="searchForm" tabindex="-1" role="dialog" aria-labelledby="searchFormLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="searchFormLabel">Search Here</h4>
</div>
<div class="modal-body">
@using (Ajax.BeginForm(new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "results",
OnSuccess = "$('#searchForm').modal('hide');"
}))
{
// input fields and submit button are here
}
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
在本例中,您将打开modalvia data-attributes,然后使用 jQuery 将其关闭。因此,在某种程度上,两种模式切换方法都被使用,它们是相互冲突的。因此,删除数据属性并modal仅使用 jQuery 显示/隐藏。
尝试这个:
$('#searchForm').modal('show'); //for showing the modal
Run Code Online (Sandbox Code Playgroud)
隐藏在 OnSuccess 上:
OnSuccess = "unloadModal"
Run Code Online (Sandbox Code Playgroud)
函数unloadModal将是:
function unloadModal() {
$('#searchForm').modal('hide');
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8253 次 |
| 最近记录: |