I have a menu that is updating based on a click event, which is pretty easy because I can base the click on the actual button, but how do I make the menu react to page changes via swiping?
Here’s my working JSFiddle that allows for clicks and swipes: http://jsfiddle.net/QFX5x/1/
I started to use pagebeforeshow and .mobile.path.parseURL for the hash tag, but it isn’t consistent.
$(document).live("pagebeforeshow", function() {
var obj = $.mobile.path.parseUrl(window.location.href);
var newPage = '.' + obj.hash;
alert(newPage);
//$(newPage).addClass("active");
//$(newPage).siblings().removeClass("active");
});
When I want to mimic some type of event I just use
.trigger()to trigger that event on the correct element rather than re-writing my code to run the event handler in two different situations. Since your code works with theclickevent, you can trigger aclickevent on the correct link based on the currentactivelist-item:Here is a demo: http://jsfiddle.net/QFX5x/4/