[英]mobile.changePage to nextPage?
How do I change the code below to swipe to the next page/ the 'to: url' w/o having to write the script for every page change? 如何更改下面的代码以滑动到下一页/“ to:url”,而不必为每次页面更改编写脚本?
<script type="text/javascript">
$('div').live("swipeleft", function(){
$.mobile.changePage("#pg02", "slide", false, true);
});
$('div').live("swiperight", function(){
$.mobile.changePage("#pg01", "slide", true, true);
});
</script>
rename your pages to pg1 pg2, ..., pg10 without the zeros in front 将页面重命名为pg1 pg2,...,pg10,前面没有零
<script type="text/javascript">
window.now=1;
$('div').live("swipeleft", function(){
window.now++
$.mobile.changePage("#pg"+window.now, "slide", false, true);
});
$('div').live("swiperight", function(){
window.now--;
$.mobile.changePage("#pg"+window.now, "slide", true, true);
});
</script>
you will have to add some if
s to guard first and last page. 您必须添加一些
if
来保护第一页和最后一页。 You might also want to put the now variable in some other object not in the global scope of window object. 您可能还希望将now变量放在其他对象中,而不放在window对象的全局范围内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.