iScroll refresh not working

3.6k Views Asked by At

I implemented iScroll-Scroller programmatically with these lines:

$(document).bind('pageinit',function( event, data ){

$("[id='menu']").attr("data-iscroll","");
$("[data-iscroll]").iscrollview();

});

Whenever i change the height of the site, e.g. by rotating the device the iscroll-wrapper doesn't adapt it's size. Meaning that i cannot scroll to the buttom anymore. So i (tried) to build a function to refresh the wrapper's size:

window.addEventListener("resize", function() {

$("[data-iscroll]").jqmData('iscrollview').refresh();

 setTimeout(function () {
$("[data-iscroll]").jqmData('iscrollview').refresh();

    }, 0)


}, false);

This doesn't work at at all and i have no idea why. Let me know if you need more code (tried to keep it as short as possible).

3

There are 3 best solutions below

0
On

My solution is:

        setTimeout(function () {
            iScroll.refresh();
            window.scrollTo(0);
        }, 10);
0
On

Why do you wanna use iScroll when jQuery Mobile supports listview and fixed header and footer??

iScroll is buggy with jQuery-mobile in my experience. I wouldn't recommend it for any developers.

0
On

try this :

$("[data-iscroll]").iscrollview().iscrollview('refresh');

then

$('[data-iscroll]').trigger('create');