Skip to content

Instantly share code, notes, and snippets.

@atomize
Created March 1, 2012 08:29
Show Gist options
  • Save atomize/1948319 to your computer and use it in GitHub Desktop.
Save atomize/1948319 to your computer and use it in GitHub Desktop.
iScroll - dynamically create scrollable containers that properly refresh with .live()
$('ui-page').live("pageinit", function (event) {
if (undefined == $(this).data('scroll')) {
$(this).data('scroll', new iScroll($(this).find('.ui-wrapper')[0]));
}
}).live("pagehide", function (event) {
$(this).data('scroll').refresh();
$(this).data('scroll').scrollTo(0,0,0);
});
function initScroll() {
document.addEventListener('touchmove', function(e){ e.preventDefault(); }, false);
}
document.addEventListener('DOMContentLoaded', initScroll, false);
document.addEventListener('DOMContentLoaded', setTimeout(function () { initScroll(); }, 200), false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment