2011-11-03 24 views
0

我不能得到這個工作:pageLoad的慣於正常工作在jQuery Mobile的

$('#guiacategs').live('pagecreate', function(event, ui) { 
    $.mobile.loadingMessage = "Carregando Categorias..."; 
    $.mobile.showPageLoadingMsg(); 

    if(CategFornsFetched == 0) { 
     $.getJSON('http://www.casamentojundiai.com.br/scripts/mobile/getguiacategs.php?callback=?', function(json) { 
      $.each(json, function(key, val) { 
       $("#listaCateg").append('<li><a href="guia.html" onclick="genForns(' + val.id + ');">' + val.descricao + '</a></li>'); 
      }); 
      $("#listaCateg").listview('refresh'); 
     }); 
     CategFornsFetched = 1; 
    } 
    $.mobile.hidePageLoadingMsg(); 
}); 

,但這個工程,我之前所說的停止加載:

$('#guiacategs').live('pagecreate', function(event, ui) { 
    $.mobile.loadingMessage = "Carregando Categorias..."; 
    $.mobile.showPageLoadingMsg(); 
    $.mobile.hidePageLoadingMsg(); 

    if(CategFornsFetched == 0) { 
     $.getJSON('http://www.casamentojundiai.com.br/scripts/mobile/getguiacategs.php?callback=?', function(json) { 
      $.each(json, function(key, val) { 
       $("#listaCateg").append('<li><a href="guia.html" onclick="genForns(' + val.id + ');">' + val.descricao + '</a></li>'); 
      }); 
      $("#listaCateg").listview('refresh'); 
     }); 
     CategFornsFetched = 1; 
    } 
}); 

感謝

回答

0

我相信頁面加載消息將被設置在移動初始化中

例子:

$(document).bind("mobileinit", function(){ 
    //apply overrides here 
    $.mobile.loadingMessage = "Carregando Categorias..."; 
}); 

那麼你應該能夠使用的方法來顯示/隱藏加載消息

例(未測試):

$('#guiacategs').live('pagecreate', function(event, ui) { 
    $.mobile.showPageLoadingMsg(); 

    if(CategFornsFetched == 0) { 
     $.getJSON('http://www.casamentojundiai.com.br/scripts/mobile/getguiacategs.php?callback=?', function(json) { 
      $.each(json, function(key, val) { 
       $("#listaCateg").append('<li><a href="guia.html" onclick="genForns(' + val.id + ');">' + val.descricao + '</a></li>'); 
      }); 
      $("#listaCateg").listview('refresh'); 
     }); 
     CategFornsFetched = 1; 
    } 
    $.mobile.hidePageLoadingMsg(); 
}); 
相關問題