2012-12-04 71 views
0

我希望在jQM和主幹網頁過渡期間顯示加載消息。但showPageLoadingMeassage不起作用。 以下是我的代碼: collection.js

findById : function(artistId, page, limit, sort) { 
    $.mobile.showPageLoadingMsg('a', 'Loading......', false); 
    var self = this; 
    if (limit == undefined) { 
     limit = 10; 
    } 
    $.mobile.showPageLoadingMsg('a', 'Loading......', false); 
    console.log("hello"); 
    $.ajax({ 
     type: "GET", 
     url: siteURL + 'artists/artist_detail/artist_id' + artistId + '.json', 
    }).done(function(msg) { 
     var response = JSON.parse(msg); 

     if (response.status == true) { 
      var dataArray = response.data; 
      console.log(dataArray); 
      self.reset(dataArray); 

      if (self.length > 0) { 
       $.mobile.hidePageLoadingMsg(); 
      } 
      //return dataArray; 
     } $.mobile.showPageLoadingMsg($.mobile.pageLoadErrorMessageTheme, 'Sorry! No records found', true); 
      setTimeout(function() { 
       $.mobile.hidePageLoadingMsg(); 
      }, 1500); 
     } 
    }); 
} 

這裏我收到錯了嗎?

編輯: 它工作時的搜索頁面:

... findByTitle : function(keyword, genre, language, page, limit, sort, collection, fan, featured) { 
      //~ console.log(page); 
      var self = this; 
      if (limit == undefined) { 
       limit = 10; 
      } 
      $.mobile.showPageLoadingMsg('a', 'Searching......', false); 
      $.ajax({.... 
+0

定義「不工作」 –

+0

不工作意味着在頁面轉換期間,加載信息不會顯示出來。 console.log(「hello」)確實被調用,但msg不顯示。希望我明確自己。 – z22

+0

你有沒有嘗試去掉AJAX調用,並簡單地將消息留在那裏而不隱藏它 - 確保它實際上顯示在所有? –

回答

3

發現計算器itself- jQuery Mobile - Problems getting showPageLoadingMsg to work with pagebeforeshow or pagebeforeceate答案。 它說,有時jQM不會將ui-loading類添加到主體中,因此我們必須手動執行。

$('body').addClass('ui-loading'); 
    $.mobile.showPageLoadingMsg('a', 'Searching......', false); 

,並同時隱藏加載消息:

setTimeout(function() { 
    $('body').removeClass('ui-loading'); //remove class 
    $.mobile.hidePageLoadingMsg(); 
}, 1000); 
+0

不錯,謝謝:) –

0

此功能也被棄用,在目前的版本是不是在所有。

相關問題