Javascript Twitter Bootstrap:如何关闭模态对话框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10944302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:42:37  来源:igfitidea点击:

Twitter Bootstrap: How to close modal dialog?

javascriptajaxtwitter-bootstrapmodal-dialog

提问by Fdr

I'm trying to implement modal loading dialog with Twitter's bootstrap. My current attemp is:

我正在尝试使用 Twitter 的引导程序实现模态加载对话框。我目前的尝试是:

$(document).ready(function () {

    $('#loading_dialog')
        .ajaxStart(function () {
            $(this).modal('show');
        })
        .ajaxStop(function () {
            $(this).modal('hide');
        });
});

Problem is that the dialog won't close.

问题是对话框不会关闭。

回答by Fabrizio D'Ammassa

I didn't test it but the issue could depend on the context of the ajaxStart/Stop anonymous function.

我没有测试它,但问题可能取决于 ajaxStart/Stop 匿名函数的上下文。

Can you try this?

你能试试这个吗?

var loading_dialog = $('#loading_dialog');
loading_dialog
    .ajaxStart(function () {
        loading_dialog.modal('show');
    })
    .ajaxStop(function () {
        loading_dialog.modal('hide');
});