Jquery mobile JqueryMobile为函数调用加载微调器

Jquery mobile JqueryMobile为函数调用加载微调器,jquery-mobile,Jquery Mobile,我想在jquerymobile中运行函数时显示加载微调器。 该函数不是ajax,它只是计算一些值并保存到sqlite数据库。 我已经搜索过,并且一直在寻找相同的例子,比如use$.mobile.showPageLoadingMsg();等等 范例 function loading() { $.mobile.showPageLoadingMsg(); //Do Some Stuff in here $.mobile.hidePageLoadingMsg(); } 提前

我想在jquerymobile中运行函数时显示加载微调器。 该函数不是ajax,它只是计算一些值并保存到sqlite数据库。 我已经搜索过,并且一直在寻找相同的例子,比如use$.mobile.showPageLoadingMsg();等等

范例

function loading()
{
    $.mobile.showPageLoadingMsg();

    //Do Some Stuff in here

    $.mobile.hidePageLoadingMsg();
}
提前谢谢。 Lmac

您只需拨打:

 $.mobile.showPageLoadingMsg();
在你提到的函数的开头,但是在函数的回调上

$.mobile.hidePageLoadingMsg();
如果您希望加载程序出现一段时间,可以使用:

$.mobile.showPageLoadingMsg();
var wait = setTimeout(function(){
    $.mobile.hidePageLoadingMsg();
},400);

使用$.mobile.load('show');和$.mobile.load('hide');相反jquery mobile文档中不推荐使用上述函数。

问题是什么?如果由于计算占用了所有的CPU,微调器似乎没有旋转,甚至没有加载其。你可以在一个循环中放置延迟,或者允许微调器绘制。嗨,Jasper,谢谢你的回答,你有延迟方法的例子吗。嗨,roman,我尝试了你的setTimeout方法,但它不起作用。感谢您的replayTimeout是一种将加载程序在屏幕上保留一段时间的方法,它可以工作,但可能不是您想要的<代码>$.mobile.showPageLoadingMsg();setTimeout(函数(){//function在这里$.mobile.hidePageLoadingMsg();},500)工作我也认为jasper使用max cpu是正确的