【问题标题】:jQuery Mobile wait until page list-view loadsjQuery Mobile 等待页面列表视图加载
【发布时间】:2014-10-13 11:54:19
【问题描述】:

我目前正在开发一个小型 JQM + PhoneGap 应用程序(这是新的)并遇到以下问题,我正在将数据从 JSON(这是本地的,还没有 AJAX)加载到列表视图,问题当我加载页面时,列表视图的 css 需要一点时间来加载,您可以看到项目符号列表半秒钟。这是我认为涉及的部分代码

<div data-role="content" id="job_offers_close_to_user_result">
    <!-- Insert job offers from JSON script here -->
    <div id="fill_with_job_offers_close_to_user_result"></div>
    <div id="view_job_offer_button"></div>
</div>
AppController.fillJobsList = function(){
$("#view_job_offer_button").append(" ");
$("#fill_with_job_offers_close_to_user_result").html(" ");
for (var i=0; i < JSON_with_jobs.ofertas.length; i++){
    $("#fill_with_job_offers_close_to_user_result").append("<ul data-role='listview'>"
        + "<li><a href='#job_description_"+i+"'>"
        + JSON_with_jobs.ofertas[i].titulo + "<br />"
        + JSON_with_jobs.ofertas[i].empresa + "<br />"
        + JSON_with_jobs.ofertas[i].contrato + "<br />"
        + JSON_with_jobs.ofertas[i].localidad + "," + JSON_with_jobs.ofertas[i].provincia + "<br />"
        + "<br />"
        +"</a></li>"
        + "</ul>"
);

点击按钮时触发此功能

<a id="mybutton2" onclick="AppController.fillJobsList()" href="#close_to_user" data-role="button">Buscar</a>

提前致谢!

【问题讨论】:

标签: javascript jquery ajax jquery-mobile cordova


【解决方案1】:

您可以使用样式代码“display:none;”来创建元素在你完成附加元素并完成处理后,显示它

$(element).show(); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-13
    • 2016-11-16
    • 1970-01-01
    相关资源
    最近更新 更多