Created
March 1, 2012 08:29
-
-
Save atomize/1948319 to your computer and use it in GitHub Desktop.
iScroll - dynamically create scrollable containers that properly refresh with .live()
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
$('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