问题描述
我有一个问题:这是我的脚本,只需单击即可调用
I have a problem:This is my script, and it is called on a click
$("#next").live("click", function() {
$.mobile.loading( 'show', {
text: 'loading',
textVisible: true,
theme: 'b',
html: ""
});
$('.giocatore').remove();
var pagina = parseInt($('#home').attr('pagina'));
$('#home').attr('pagina',pagina+1);
$('#back').append('<a id="prev" data-role="button" data-theme="a" href="" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left">Prec</a>').trigger('create');
caricalista();
});
它对我的网页有帮助.我希望在执行某项操作时,当我在jquery mobile中从页面传递到页面时,页面向我显示一条加载消息或某种过渡,例如"pop".
It does something to my webpage. I want that during the time it does something, the page shows me a loading message or some transition like the "pop" when i pass from page to page in jquery mobile.
现在使用我的代码,页面将向我显示加载消息,但在执行脚本后仍会保留
Now with my code the page display me the loading message but it remain also after the script is executed
有人可以帮助我吗?
推荐答案
您可以使用自定义事件.
You can use a custom event.
完成您的工作后,只需触发一个通知,即已完成.将此行添加到现有功能的最后一个行中:
after you done with your work just trigger an announcement that it is done. Add this line to very last of your existing function:
$(document).trigger('customEvent');
现在在该功能之外,可以订阅该公告:
now outside of the function make a subscription to that announcement:
$(document).on('customEvent', function () {
// hide your loading message
});
希望获得帮助
这篇关于jQuery Mobile中的过渡加载消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!