jQuery Mobile-使showPageLoadingMsg与pagebeforeshow或pagebeforeceate一起使用时出现问题 [英] jQuery Mobile - Problems getting showPageLoadingMsg to work with pagebeforeshow or pagebeforeceate

查看:148
本文介绍了jQuery Mobile-使showPageLoadingMsg与pagebeforeshow或pagebeforeceate一起使用时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第二周我正试图解决此问题,以使加载消息正确显示:-(

I'm on my second week of trying to resolve this issue of getting a load message to properly display :-(

我只是非常艰难地获取pagebeforecreate或pagebeforeshow事件来触发$ .mobile.showPageLoadingMsg().

I'm just having a very tough time getting either the pagebeforecreate or the pagebeforeshow events to fire the $.mobile.showPageLoadingMsg().

这是jsfiddle上的示例的链接:

Here's a link to example on jsfiddle:

    [http://jsfiddle.net/7fxQf/25/][1]

请注意,jsFiddle正在引用移动1.0b3库.

Note the jsFiddle is referencing the mobile 1.0b3 library.

这是应该起作用的基本代码片段的示例,但无效:

Here's sample of the basic code snippet that should work, but does not:

$('#mypageone').live('pagebeforecreate', function (event, ui) {
   alert('Just selected page one!');
   //HEY!!! the page load never pops up :-(
   $.mobile.loadingMessage = "this msg set on live pageshow from mypageone...";
   $.mobile.pageLoading();
   $.mobile.showPageLoadingMsg();
  calcLongList();  //simple list generation of a 1000 lines to screen
 //$.mobile.hidePageLoadingMsg();
});

当页面实际加载时,我可以触发警报,但不幸的是,加载消息无法触发.

I can get the alert to fire, but sadly not the load message, when a page is actually loading.

...但是,如果仅更改为"pageshow",则会显示加载消息,但是当然,在生成列表之后需要5到10秒钟:-( ...当然不是我所需要的想要.

...but however, if change to just "pageshow", the load message will display, but of course after the 5-10 seconds it takes to generate the list :-( ...which is certainly not what I want.

此外,是否注释掉calcLongList函数也没关系...页面加载消息的行为相同:适用于'pageshow'...但不适用于'pagebeforeshow'或'pagebeforecreate'. ..而我正在拔头发试图找出我可能做错了什么?

Also, it does not matter if I comment out the calcLongList function or not...the page load msg behaves the same: works for 'pageshow'...but not for the 'pagebeforeshow' or the 'pagebeforecreate'...and I'm pulling my hair out trying to figure out what I might be doing wrong?

任何建议或指导都将不胜感激,在此先感谢

Any advice or guidance would sure be appreciated, thanks in advance

推荐答案

当jQM显示加载指示符时,它将向$ .mobile.hidePageLoadingMsg()删除的html对象(.ui-loading)中添加一个类.不过在某些情况下,它不会将此类添加到html中(因为它不能-尝试手动添加).

When jQM shows the loading indicator, it adds a class to the html object (.ui-loading) that it removes with $.mobile.hidePageLoadingMsg(). In some cases though, it won't add this class to the html (because it can't - try adding it manually).

简单(且稍脏)的修复程序是手动将类添加到html对象,而不是添加到正文:

Easy (and slightly dirty) fix is manually adding the class not to the html object, but to the body:

$('body').addClass('ui-loading');

要删除加载微调器,只需再次删除该类:

To remove the loading spinner, simple remove the class again:

$('body').removeClass('ui-loading');

这篇关于jQuery Mobile-使showPageLoadingMsg与pagebeforeshow或pagebeforeceate一起使用时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆