I'm creating a hybrid app using JQM. One of the pages is an image gallery where I use Touchswipe.
If I open the page directly everything works fine. But if I navigate to this page by clicking a link from another page, JQM loads the page using Ajax and swipe
is not initialized correctly. If I try to swipe, I get this error:
It only works if I hit F5 and reload the page.
This is the code I use:
$(document).on( "pagecontainerbeforeshow", function( e, ui ) {
Gallery.init();
});
var Gallery = {
imgContainer: null,
(...),
init: function() {
this.imgContainer = $('#imageContainer');
(...)
console.log('This msg shows');
this.imgContainer.swipe({
threshold : 100,
triggerOnTouchEnd: true,
allowPageScroll : "horizontal",
swipeStatus : function (event, phase, direction, distance, duration) {
Gallery.swipe(event, phase, direction, distance, duration)
}
});
},
swipe: function(...){
console.log('I only get this by hitting F5');
}
};
Any help is greatly appreciated!