如何在页面加载结束之外继续显示jQuery Mobile微调器?

时间:2012-10-19 23:13:45

标签: javascript jquery-mobile

jQuery Mobile完成页面加载后,微调器消失。我希望微调器保持到某个事件之后(数据从服务器到达):

$('#form').live('pagebeforeshow', function(){
   var def = $.Deferred();

   $.post('url', obj)
      .success(function (response) {
         def.resolve();
      });

   def.done(function(){
      // I want the spinner to disappear now.
   });
});
// in this point, once the 'pagebeforeshow' handler is returned,
// the spinner disappears - but I want it to stay only after def is resolved.

(顺便说一下,我觉得找到旋转器被移除的位置会更简单,并在此之后重新显示它。我希望找到一个更优雅的解决方案,不会有这种风险(尽管风险很小) ,但仍然......)有那种闪烁)

1 个答案:

答案 0 :(得分:1)

尝试在.mobile.loading( 'show')上添加$('#form').live('pageshow', function(),当事件完成后,您可以使用.mobile.loading( 'hide')