iScroll refresh() help

333 views
Skip to first unread message

Aimee Walker

unread,
Mar 12, 2012, 5:22:47 PM3/12/12
to isc...@googlegroups.com
I'm not very good with Javascript, so I'm having a hard time implementing the refresh method so I can have the scroll height refresh when loading new content. I have my content in a jQuery tabs environment, and I need it to reload the scroll every time the user clicks to switch to a new tab. I added the following code to my script, but I'm not sure how to tell it the refresh needs to happen upon switching to a new tab:

ajax('index.html', onCompletion);

function onCompletion () {
// Here modify the DOM in any way, eg: by adding LIs to the scroller UL

setTimeout(function () {
myScroll.refresh();
}, 0);
};

I'm a student taking one of my first few web development classes trying to build a mobile web app. This is what I get for trying to go above and beyond the assignment parameters! Any help in getting this to work would be greatly appreciated!

The example I am working with is here: http://aimeeannwalker.com/nms509

Kerri Shotts

unread,
Mar 13, 2012, 5:59:26 PM3/13/12
to isc...@googlegroups.com
You /always/ should refresh() your scroller after loading the content. Setting a timeout is the proper way to permit the DOM some time to update itself so that the refresh() function can get a good height. If 0ms isn't giving sufficient time (say, a complicated document), try 50, 100, or 150ms.

Depending on where you've put your scroller and how the content is loading, you may actually be nuking the scroller itself. In that case, you'll need to re-create it.
Reply all
Reply to author
Forward
0 new messages