0
我试图让我的ASP.NET Razor应用程序中的表单提交对话框(bootbox)工作。我有这样的JavaScript代码:Bootbox在表单上确认提交
$(document).on("click", "#submit", function (e) {
e.preventDefault();
var $this = $(this);
bootbox.confirm("Are you sure for your choice: " + $this.val() + "?", function (result) {
if (result) {
$this.submit();
} else {
console.log("user declined");
}
});
});
而且我的按钮是:
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button type="submit" id ="submit" class="btn btn-default"><span class="glyphicon glyphicon-floppy-save"></span></button>
</div>
</div>
</div>
然而,它没有在所有的工作。我已经导入了库等,并检查它们是否在Chrome中加载。
编辑 更新了代码(参见上文)。现在出现Bootbox对话框,但表单不提交。如果单击“确定”时表单中存在验证错误,它将通知用户。但是,一旦错误被清除,然后他们尝试提交,它不会提交表单并且什么都不会发生。
好吧这就是工作,但是当我按OK按钮 – ASPCoder1450
都能跟得上形式不提交,为什么会呢? – adeneo
啊我现在看到忘了实际上告诉它提交表单。全部排序。谢谢! – ASPCoder1450