jquery Loader Widget没有显示

时间:2013-10-29 16:20:28

标签: jquery jquery-mobile jquery-plugins

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

我的代码如下

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

这是我因使用加载程序小部件而遗漏的任何内容吗?

1 个答案:

答案 0 :(得分:5)

jQuery Mobile 1.3.2 起,<{$.mobile.showPageLoadingMsg();$.mobile.hidePageLoadingMsg();$.mobile.loading('show');$.mobile.loading('hide');取代。

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

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

  

<强> Demo