简体   繁体   English

带有加载微调器的jQuery移动弹出窗口

[英]Jquery mobile popup with loading spinner

The popup delays a long time to load in device. 弹出窗口会延迟很长时间加载设备。

How can I show a loading spinner before display a popup in jquery mobile? 在jquery mobile中显示弹出窗口之前,如何显示加载微调框?

This is a simplified version of my code: 这是我的代码的简化版本:

HTML 的HTML

<div data-role="page" id="fixed_numbers">
    <div data-role="header">
        <a href="#" data-icon="back" data-rel="back" data-role="button">Back</a>
        <h1>Header</h1>                  
    </div>
    <div data-role="content">
        <div id="dlg_fix" data-role="popup" data-theme="a" data-overlay-theme="a"></div>
        <a href="#" id="fix_num_btn" data-value="test">Click Here!</a>
    </div>
</div>

Javascript Java脚本

$(document).on("pageinit", "#fixed_numbers", function() {

    $("#fixed_numbers").on("click", "#fix_num_btn", function(e) {
        e.preventDefault();
        // value receive a data from input hidden  
        var value = $(this).attr("data-value");
        $('#dlg_fix').html(value).popup('open');
    });
});

Thanks 谢谢

$(document).on("pageinit", "#fixed_numbers", function() {

    $("#fixed_numbers").on("click", "#fix_num_btn", function(e) {

        $.mobile.showPageLoadingMsg();

        e.preventDefault();
        // value receive a data from input hidden  
        var value = $(this).attr("data-value");
        $('#dlg_fix').html(value).popup('open');

    });
});

see more page loading msg options from jQuery Mobile 查看更多页面从jQuery Mobile加载msg选项

Try this: 尝试这个:

$("#fixed_numbers").on("click", "#fix_num_btn", function(e) {

    e.preventDefault();

    $.mobile.showPageLoadingMsg(); //Show  Sipnner
    var value = $(this).attr("data-value");
    $('#dlg_fix').html(value).popup('open');

});

Add a popupafteropen event listener, this will hide the spinner when the popup will be open. 添加一个popupafteropen事件侦听器,当弹出窗口打开时,它将隐藏微调器。

$('#dlg_fix').on('popupafteropen', function (e) {
$.mobile.hidePageLoadingMsg();
});

live demo 现场演示

for more popup events, check out JQM docs jqm docs - popup events 有关更多弹出事件,请查看JQM文档jqm文档-弹出事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM