Created
March 27, 2013 20:20
-
-
Save dalethedeveloper/5257672 to your computer and use it in GitHub Desktop.
jQuery Mobile - implement anchor links in existing HTML with scrollTo
Written specifically against 1.2.0 functionality of "pagechange" event after enhancements have taken place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('pagechange',function(e,ui){ | |
$('a[href^="#"]',ui.toPage).on('click',function(){ | |
var selector = 'a[name="'+($(this).attr('href').substring(1))+'"]', | |
target = $(selector).get(0).offsetTop; | |
$.mobile.silentScroll(target) | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment