2012-03-30 56 views
0

我在rhomobile和jquery mobile中创建应用程序。我尝试在我的页面中使用2个iscroll。在我的页面中,我有2个李。最初左边李是空的。当我点击右侧李将添加到左侧李,并从右侧李删除。最初我使用滚动查看右侧李的元素。这工作正常。但在左侧,当内容超出高度时,iscroll不会到来。我搜索了很多。我收到了一些建议,但这对我不起作用。这些都是在dom内容更改后引入isroll

首先添加checkDOMChanges: true在我的选项,然后设置超时如:setTimeout(function() { myScroll.refresh() }, 0)

我的右侧UL id为accounts_container,左侧UL标识是destinations_container

我的代码:

var destinations_scroll1, accounts_scroll; 
function loaded() { 
    destinations_scroll1 = new iScroll('destinations_container'); 
    accounts_scroll = new iScroll('accounts_container', { 
     checkDOMChanges: true 
    }); 
setTimeout(function() { accounts_scroll.refresh() }, 0) 
} 
document.addEventListener('touchmove', function (e) { 
    e.preventDefault(); 
}, false); 
document.addEventListener('DOMContentLoaded', loaded, false); 

然后根据此链接 http://groups.google.com/group/iscroll/browse_thread/thread/6bdf7a2b5552d018

我想

destinations_scroll1.destroy(); 
destinations_scroll1= null; 
destinations_scroll1= new iScroll('destinations_container'); 

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

在rhosimulator这个创造正常的CSS滚动,但在仿真器(实色器件)无法正常工作。

有什么建议吗?

回答

0

我是个白痴。在上面的代码中,我正在检查checkDomChanges并刷新右侧的isroll对象ul,但我在左侧ul添加了动态内容。

var destinations_scroll1, accounts_scroll; 
function loaded() { 
    accounts_scroll = new iScroll('accounts_container'); 
    destinations_scroll1 = new iScroll('destinations_container', { checkDOMChanges: true }); 
    setTimeout(function() {    
      destinations_scroll1.refresh();  
    }, 0); 
} 
document.addEventListener('touchmove', function (e) { 
    e.preventDefault(); 
}, false); 
document.addEventListener('DOMContentLoaded', loaded, false); 

这工作正常。