0

我正在尝试让表单提交对话框(引导框)在我的 ASP.NET Razor 应用程序中工作。我有这个 JavaScript 代码:

   $(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 对话框,但不会提交表单。如果当我单击“确定”时表单中存在验证错误,它将通知用户。但是,一旦错误被清除,然后他们尝试提交,它就不会提交表单,也没有任何反应。

4

1 回答 1

0

尝试定位实际 ID

$(document).on("click", "#submit", function (e) { ...
             //          ^^ the hash is important ...
于 2014-03-02T22:06:22.633 回答