Skip to content

Instantly share code, notes, and snippets.

@dalethedeveloper
Created March 27, 2013 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalethedeveloper/5257672 to your computer and use it in GitHub Desktop.
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.
$(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