[英]jQuery Mobile close dialog and load a different page
In jQuery mobile, is it possible when a user opens a new page (lets say example.html), to 在jQuery mobile中,当用户打开新页面(例如example.html)时,
I've setup the dialog but not sure what to do to fade in/fade out the dialog box. 我已经设置了对话框,但是不确定如何淡入/淡出对话框。
<div data-role="page">
// page
</div>
<div data-role="dialog">
// dialog box fades in, 3 seconds later, fade out
</div>
Annotate the page and the dialog with a unique id and bind something like this to the pageshow
event of the page: 用唯一的ID注释页面和对话框,并将类似以下内容绑定到页面的
pageshow
事件:
jQuery('#myPageId').bind('pageshow', function() {
var me = jQuery(this);
var dialogShown = me.data('dialogShown');
var dialog = jQuery('#myDialogId');
if(!dialogShown) {
me.data('dialogShown', true);
dialog.one('pageshow', function() {
setTimeout(function() { window.history.back(); }, '3000');
});
jQuery.mobile.changePage(dialog, {transition: 'fade'});
}
});
Use the fadeOut
method and you should be able to fade the dialog. 使用
fadeOut
方法,您应该能够淡化对话框。 Then set a timer to call that 3 seconds after the page has loaded. 然后设置一个计时器,以在页面加载后3秒钟调用该计时器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.