[英]iScroll refresh not working
I implemented iScroll-Scroller programmatically with these lines: 我使用以下代码以编程方式实现了iScroll-Scroller:
$(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. 每当我更改站点的高度时,例如通过旋转设备,iscroll-wrapper都不适应其大小。 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?? 当jQuery Mobile支持listview和固定的页眉和页脚时,为什么要使用
iScroll
?
iScroll
is buggy with jQuery-mobile in my experience. iScroll
我的经验, iScroll
在使用jQuery-mobile时存在很多问题。 I wouldn't recommend it for any developers. 我不会推荐给任何开发人员。
try this : 尝试这个 :
$("[data-iscroll]").iscrollview().iscrollview('refresh');
then 然后
$('[data-iscroll]').trigger('create');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.