Updating Divs when observable collection changes

Go To StackoverFlow.com


Is there any plugin or jquery utility that will update my list of divs bound to an observable collection when items get added/removed to that collection? We have 1000s of items and so are looking for the most optimal way to add/remove divs when the bound list changes.

We would be interested in hearing about this in KO or jquery.tmpl.

2012-04-04 06:44
by Amar
What do you want it to do that KO doesn't already do - Tuan 2012-04-04 06:55
I'd accept some more answers to your previous questions before posting more... it will greatly increase the chance of having this answere - isNaN1247 2012-04-04 07:36


This is maybe not the answer that your looking for, but it could be one way to do it. I would wrap the array within an object that has an Add and Remove method(or other function that change the array)

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


You can now call




to change your javascript collection. Both will update your pagedivs.

2012-06-05 15:45
by Ruben-J