简体   繁体   中英

iScroll refresh not working

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, eg 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).

My solution is:

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

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.

try this :

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

then

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM