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

时间:2022-05-25 19:36:45

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.

问题是对话框不会关闭。

1 个解决方案

#1


28  

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');
});

#1


28  

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');
});