Jquery append function and iScroll

237 views
Skip to first unread message

Richard Kronborg Svendsen

unread,
Feb 28, 2012, 8:26:15 AM2/28/12
to isc...@googlegroups.com
Hi.

I have a small strange problem. :)

I have a div that i have hooked up with iScroll. This div has a lot of text in it so I know iScroll is working properly.
I have another div width some buttons, that I uses to insert divs inside the iScroll div with the jquery append command. This is also working fine.

But it is here my problem begins: 
I have tried to refresh the iScroll to "update" the div. But I cant scroll down far enough to the new content in the div. If I just hold the mouse button down while I drag the scroll up, I can see the new content, but when I release the button it goes up again.
For me it looks like it can't see the new content when I do a refresh.

Hope somebody has someway to solve this.

Thanx in advance.

Best Regards
Richard
Message has been deleted

Richard Kronborg Svendsen

unread,
Feb 28, 2012, 8:55:36 AM2/28/12
to isc...@googlegroups.com
I found a solution.

You have to destroy the iScroll and init it again. Like this:

myScroll2.destroy();
myScroll2 = null;
myScroll2 = new iScroll('desktop21');

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

This works. :)

Best Regards
Richard

Kerri Shotts

unread,
Feb 28, 2012, 4:18:31 PM2/28/12
to isc...@googlegroups.com
Best to add a try...catch to around the destroy()... I've found that on rare occasions the destroy returns an error, which means the rest of the code wouldn't be executed. 

(Not sure /why/, though. I couldn't track it down, hence the try/catch)
Reply all
Reply to author
Forward
0 new messages