1

我需要在每个页面更改或某些元素(a,input[button,submit],data-role=button)单击事件显示加载消息。我试过这段代码:

$(document).live(`pagebeforehide`, function(){
    $.mobile.showPageLoadingMsg();
    //More stuff to do
});

但它不起作用。

4

1 回答 1

0

我认为您可以在全局配置中进行设置:

loadingMessage 字符串,默认值:“
正在加载” 设置页面加载时显示的文本。如果设置为 false,则消息根本不会出现。

loadingMessageTextVisible 布尔值,默认值:false
显示加载消息时文本是否可见。对于加载错误,文本始终可见。

这是 $.mobile.showPageLoadingMsg 方法的文档

这是一个使用带有点击事件的加载消息/微调器的示例

JS

$("input, a:jqmData(clickload='show')").on('click', function() {
    console.log('clicked show');
    $.mobile.showPageLoadingMsg("b", "This is only a test", true);
});

$("input, a:jqmData(clickload='spin')").on('click', function() {
    console.log('clicked spin');
    $.mobile.showPageLoadingMsg("b", "This is only a test", false);
});

$("input, a:jqmData(clickload='hide')").on('click', function() {
    console.log('clicked hide');
    $.mobile.hidePageLoadingMsg();
});

HTML

<div data-role="controlgroup" data-type="horizontal">
    <a href="#" id="showMe" data-role="button" data-clickload="show">Show Loading Message</a>
    <a href="#" id="showMe" data-role="button" data-clickload="spin">Show Loading Spinner</a>
    <a href="#" id="hideMe" data-role="button" data-clickload="hide">Hide Loading Message/Spinner</a>
</div>
于 2012-06-28T13:40:56.713 回答