So, the method that I am using to solve this problem right now, I have added a numbered index to each of my html template sections, for example:
<div id="list"> <div id="items-start"></div> {#foreach $T as item} <div id="item-{$T.item$index}" class="item"> ...lots of stuff... </div> {#/for} </div>
Then in my json elements, I added the InitialIndex attribute to keep track of which dom element is associated with each element in json. Thus, after making any changes to my json data, I can call this simple function to apply the changes to dom:
function applyListChanges(items) { $('.item').hide(); for (var item in items) { var index = items[item].InitialIndex; $('#items-start').append($('#item-' + index)); $('#item-' + index).show(); } }
Please let me know if you have a better solution.
source share