Twitter的引导:如何关闭模态对话框?对话框、模态、Twitter

2023-09-10 17:11:43 作者:对你没興趣

我试图实现与Twitter的引导模式加载对话框。我现在学尝试为:

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

$(document).ready(function () {

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

问题是,对话框将不会关闭。

Problem is that the dialog won't close.

推荐答案

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

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

您可以试试这个?

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