|||
先说结论:
$(document).on('ready', function(){
//这里是你的事件
});
下面我们来分析一下,首先看一下page的事件顺序,可参考:
http://www.gajotres.net/page-events-order-in-jquery-mobile-version-1-4-update/
http://www.gajotres.net/page-events-order-in-jquery-mobile/
这里做个截图:
注意上图中的complete对应的是ready()事件。
可以利用
event.zip (或者看这里:http://jsfiddle.net/Gajotres/QGnft/ )
里面的方法来查看事件顺序:
我给增加了一个window的onload事件,注意:window和document的事件区别,参考:
http://blog.sina.com.cn/s/blog_74f1a3280102uyxp.html
一个完整的主页面调用为:
<a href="detailactivity.html?id=8" data-ajax="true" data-transition="flip" id="8"><img src="http://www.gobaby.im:9090/gobaby/img/icon/todo.png" class="activity_img" height="200px">
返回页面为:
<a href="javascript:void(0);" data-rel="back" class="ui-btn ui-icon-arrow-l ui-btn-icon-notext ui-corner-all">返回
另外判断是否返回的js代码为:
$(window).on("navigate", function(event, data) {
alert("navigate");
if (data.state.direction == "back") {
alert("User navigated back.");
}
});
其他一些有用的链接:
http://demos.jquerymobile.com/1.2.0/docs/api/events.html
http://api.jquerymobile.com/mobileinit/
http://stackoverflow.com/questions/25175350/is-there-an-event-that-occurs-after-data-rel-back
加我私人微信,交流技术。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-10-19 21:33
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社