我对 jQueryMobile 有疑问,我搜索了好几个小时的答案,但没有任何效果:(
我可以通过向左或向右滑动来移动下一个或上一个项目。
上面的代码工作正常,但过了一段时间它变得疯狂。
我在“A 区”,向右滑动,然后“B 区”,向左滑动,返回“A”,然后再次向右滑动,进入“C”,如果我滑动,则在“C”上一次又是连接的旋转木马
我从页面 C 传递到 A,然后我回到 B 返回 C 等等……经过十年的改变,它停在一个页面上,我滑动这更像是一个完全疯狂的滚动显示效果
下一个和上一个是网址
在 HTML 中
<div data-role="page" data-dom-cache="false" class="actus-page" id="news" data-theme="a" data-next="http://wip17.kenjidev.com/n/39409" data-prev="http://wip17.kenjidev.com/n/39423" data-title="La vitalité de la traduction, levier décisif de la diversité éditoriale">
如果我把线路加载页面,这个费用有一个无限的ajax页面(有超过50 000个项目..)
和js
$( document ).on( "pageinit", "[data-role='page'].actus-page", function() {
var page = "#" + $( this ).attr( "id" ),
next = $( this ).jqmData( "next" ),
prev = $( this ).jqmData( "prev" );
if ( next ) {
//$.mobile.loadPage( next + ".htm" );
$( document ).on( "swipeleft", page, function() {
console.log(next +' : ' + page + ' : ' + prev );
$.mobile.changePage( next , {transition: "slide"});
});
}
if ( prev ) {
$( document ).on( "swiperight", page, function() {
console.log(prev +' : ' + page + ' : ' + next );
$.mobile.changePage( prev, { transition: "slide" , reverse: true } );
});
}
});
感谢帮助
编辑:已解决
感谢奥马尔的帮助
最后这里的代码解决了所有问题:
$( document ).on( "pageinit", ".actus-page", function() {
var
$page = $(this),
page = "#" + $page.attr( "id" ),
next = $page.jqmData( "next" ),
prev = $page.jqmData( "prev" );
if ( next ) {
$page.on( "swipeleft", function() {
$.mobile.changePage( next , {transition: "slide"});
});
}
if ( prev ) {
$page.on( "swiperight", function() {
$.mobile.changePage( prev, { transition: "slide" , reverse: true} );
});
}});