【问题标题】:PageLoad Wont work properly on jQuery MobilePageLoad 在 jQuery Mobile 上无法正常工作
【发布时间】:2011-11-03 22:07:41
【问题描述】:

我不能让它工作:

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

谢谢

【问题讨论】:

    标签: jquery android html jquery-mobile


    【解决方案1】:

    我相信页面加载消息将在 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();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-22
      • 1970-01-01
      • 1970-01-01
      • 2014-06-16
      • 2013-09-15
      • 1970-01-01
      • 2014-02-10
      • 1970-01-01
      相关资源
      最近更新 更多