[英]jQuery mobile pagecontainer change not working on swipe
我正在使用jqm 1.4.5。
我希望頁面在用戶向左和向右滑動時更改。
因此,我創建了以下代碼:
$( document ).on( "pageinit", ".my-page", function() {
$( document ).on( "swipeleft swiperight", ".my-page", function( e ) {
var prevLink = <some url>;
var nextLink = <some url>;
if ( e.type === "swipeleft" ) {
$( ":mobile-pagecontainer" ).pagecontainer( "change", nextLink, { reloadPage: true});
} else if ( e.type === "swiperight" ) {
$( ":mobile-pagecontainer" ).pagecontainer( "change", prevLink, { reloadPage: true});
}
}
});
我在控制台日志上收到此錯誤:
Uncaught TypeError: Cannot read property '0' of undefined
符合以下代碼:
$( ":mobile-pagecontainer" ).pagecontainer( "change", nextLink, { reloadPage: true});
因此,經過長時間的搜索,我找到了答案。
只需更改:
$( ":mobile-pagecontainer" ).pagecontainer( "change", nextLink, { reloadPage: true});
至:
$.mobile.pageContainer.pagecontainer("change", nextLink);
奇跡般有效 :-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.