javascript - 提交模式弹出窗口时无法禁用 .btn-default

标签 javascript jquery twitter-bootstrap

我正在开发 asp.net vmc5,并且使用 bootstrap 3.0 和 jQuery 1.10.2,现在我编写了以下脚本:

function bindForm(dialog) {
    $('form', dialog).submit(function () {
        $('.btn btn-default').prop("disabled", "disabled");
        $('#progress').show();
        if ($(this).valid()) {

            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),

我提交的模式弹出窗口如下所示:-

 <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" /> |  @Html.ActionLink("Back to List", "Index")
            </div>
        </div>
    </div>
}
<span id="progress" class="text-center" style="display: none;">
                <img src="~/img/ajax-loaders/ajax-loader-5.gif" alt="wait" />
                Wait..
            </span>

但是现在当我提交表单时,将显示进度图像(如脚本内所述),但提交按钮不会被禁用?有人可以对此提出建议吗? 谢谢

最佳答案

您的选择器无效,请尝试以下操作:-

 $('.btn.btn-default').prop("disabled", "disabled");

关于javascript - 提交模式弹出窗口时无法禁用 .btn-default,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28111273/

相关文章:

javascript - polymer 以声明方式将监听器附加到组件

javascript - 如果您只是从 npm 下载它,为什么要将 node_modules 包含在 .gitignore 文件中?

css - Bootstrap 中的行类有什么用?

javascript - 检测 ES 模块是否从 Node 中的命令行运行

javascript - 文件更改时 Node 编译

javascript - 关闭 JavaScript 切换

javascript - 水平重叠两个 DIVS

javascript - 尽管有 Scripts.Render 顺序,但 Razor 为使用它的自定义脚本生成 jQuery 太迟了

PHP PDO 尝试在登录时更改导航栏

javascript - 关闭 Bootstrap 模式后重置验证消息