PageLoad不能在jQuery Mobile上正常工作

时间:2011-11-03 11:14:13

标签: jquery android html 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;
    }
});

由于

1 个答案:

答案 0 :(得分:0)

我相信将在Mobile Init

中设置页面加载消息

示例:

$(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();
});