【问题标题】:jquery Loader Widget not showingjquery Loader Widget 未显示
【发布时间】:2013-11-08 22:28:52
【问题描述】:

我正在通过 Ajax 调用使用 Jquery 移动加载器小部件,在函数调用 LoadingData 期间它应该显示加载掩码,但它没有显示任何加载掩码,一旦完成它就会直接弹出结果。

我的代码如下

$(document).on('pageinit', function(){
            $.ajax({url: "SomeURL",
                beforeSend: function() { $.mobile.showPageLoadingMsg(); }, //Show spinner
                complete: function() { $.mobile.hidePageLoadingMsg(); }, //Hide spinner

                success: function (result) {
                    LoadingData(result);
                },
                error: function (request,error) {
                    alert('Network error has occurred please try again!');
                }
            });   
        });

这是我为使用加载器小部件而遗漏的任何东西吗??

【问题讨论】:

    标签: jquery jquery-mobile jquery-plugins


    【解决方案1】:

    $.mobile.showPageLoadingMsg();$.mobile.hidePageLoadingMsg();jQuery Mobile 1.3.2 开始被 $.mobile.loading('show');$.mobile.loading('hide'); 替换。

    但是,在 pageinit 上使用它们需要设置时间间隔,直到页面完全初始化。

    在其他事件上,例如pagebeforeshowpageshow,可以立即调用它们。

    Demo

    【讨论】:

    • 如何将它添加到我的 ajax 中?
    • 只需用@abccba 声明的新功能替换旧功能
    • 我替换 $.mobile.showPageLoadingMsg();与 $.mobile.loading('show');但它没有显示任何内容。
    • @abccba 将其包装在 setTimeout 函数中,查看我的演示。如果您将 pageinit 替换为 pageshow 它将起作用。
    • 你的意思是我的 ajax 调用也必须在 setTimeout 内?
    猜你喜欢
    • 2020-10-23
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多