Jquery 单击提交按钮后关闭模式(ajax成功)
我知道这个问题在StackOverflow中已经被问过好几次了,但我不能在给出建议的情况下让它工作 所以基本上我有这个模式在我看来:Jquery 单击提交按钮后关闭模式(ajax成功),jquery,ajax,twitter-bootstrap,modal-dialog,bootstrap-modal,Jquery,Ajax,Twitter Bootstrap,Modal Dialog,Bootstrap Modal,我知道这个问题在StackOverflow中已经被问过好几次了,但我不能在给出建议的情况下让它工作 所以基本上我有这个模式在我看来: <div id="createFolderModal" class="modal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <!- (..
<div id="createFolderModal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<!- (...) -->
</div>
<div class="modal-body">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<!- (...) -->
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" onclick="createFolder()">Create</button>
</div>
</div>
</div>
那么我的剧本是:
function createFolder() {
// (...)
$.ajax({
type: "Post",
url: '@Url.Action("CreateFolder", "ManageFiles")',
data: { name: path },
dataType: "json",
traditional: true,
success: function (data) {
//close the modal
$('#createFolderModal').modal('hide');
//$('#createFolderModal').modal('toggle');
document.getElementById("inputFolderName").value = ""; // to empty the input field
}
});
}
所以,正如你所看到的,我已经尝试了下面的说明,但都没有奏效。在所有关于StackOverflow的帖子中,这是唯一的建议,所以我不知道在我的情况下会有什么错误
$('#createFolderModal').modal('hide');
$('#createFolderModal').modal('toggle');
还在我的按钮中尝试了data dismission=“modal”,但没有成功
提前感谢您的帮助。代替
$('#createFolderModal').modal();
使用
然后
$('#createFolderModal').modal('hide'); to hide it.
你能用这个
$('#createFolderModel')检查一下吗代码>如何$('#CreateFolderModel')。隐藏()代码>?如果要关闭模式,必须使用模式(“显示”)
或模式(“隐藏”)
。不show()
/hide()
method@BasantaMatia谢谢你的建议,但对我来说没有用。@Ignatius非常感谢,它奏效了@我的用户名21试试这个solution@myusername21,这是bootstrap推荐的方法。
$('#createFolderModal').show(); to open the dialog
$('#createFolderModal').modal('hide'); to hide it.