2012-04-04 95 views
3

是否有任何插件或jQuery实用程序将更新绑定到可观察集合的div列表,当项目被添加/删除到该集合时?我们有1000个项目,因此在绑定列表更改时寻找最佳方式来添加/删除div。当可观察的集合更改时更新Div

我们希望在KO或jquery.tmpl中了解到这一点。

+0

你想要做什么,KO还没有做什么? – Tuan 2012-04-04 06:55:42

+2

在发布更多内容之前,我会接受您之前问题的更多答案......这将大大增加获得此答案的机会 – isNaN1247 2012-04-04 07:36:40

回答

1

这可能不是您寻找的答案,但它可能是一种方法。 我想包有一个添加的对象中的数组和删除方法(或其他函数改变数组)

var Collection = (function() { 
    var collectionArray = new Array(); 
    //"private" methods 
    function updatePageDivs() 
    { 
     //Logic to update your Divs 
    } 
    //"public" methods 
    return{ 
     Add: function(element){ 
      collectionArray[collectionArray.length] = element; 
      updatePageDivs(); 
     }, 
     Remove: function(element){ 
      //other logic to remove elements and to trigger the updatePage 
     } 
    } 

}); 

现在,您可以拨打

Collection.Add() 

Collection.Remove() 

更改您的JavaScript集合。两者都会更新你的pagedivs。

相关问题