当我使用jquery mobile从一个页面移动到另一个页面时如何显示进度对话框?

时间:2012-02-17 07:16:24

标签: javascript jquery jquery-mobile

我正在使用jquery mobile开发应用程序.. 在那里我想显示从一个页面到另一个页面的进度对话框。

我试过了

$.mobile.showPageLoadingMsg();

但显示时需要一段特定的时间......

实际上我的其他页面加载的图表很少,所以需要时间...... 一旦图表加载到另一页上,我们如何才能显示进度?

3 个答案:

答案 0 :(得分:1)

我认为您可以利用 pagebeforecreate或pagecreatelike 等事件 并且将$ .mobile.showPageLoadingMsg()放置在代码中的适当位置可能会产生重大影响。

$('#aboutPage').live('pagebeforecreate',function(event){
  alert('This page was just inserted into the dom!');
});  
$('#aboutPage').live('pagecreate',function(event){
  alert('This page was just enhanced by jQuery Mobile!');
});

你可以像以下一样: http://jquerymobile.com/demos/1.0a3/#docs/api/events.html

答案 1 :(得分:0)

围绕它

$(document).ready(function() { ... }

如果你还没有

答案 2 :(得分:0)

如果您使用AJAX在页面之间切换,您可以执行以下操作:

jQuery.ajaxSetup({
  beforeSend: function() {
     $('#loadingDiv').show()
  },
  complete: function(){
     $('#loadingDiv').hide()
  },
  success: function() {}
});

“loadingDiv”是带有spinner gif图像的容器(例如)。