PDA

View Full Version : TemplateView.js, bug in refreshNodes()



next
20 Jan 2007, 2:19 AM
Hi Jack,

thanks four your unbelievable work on yui ext!

I think I ran into a bug in TemplateView.js:


YAHOO.ext.View.refreshNodes : function(dm, startIndex, endIndex){
this.clearSelections();
var dm = this.dataModel;
var ns = this.nodes;
for(var i = startIndex; i <= endIndex; i++){
var d = this.prepareData(dm.getRow(i), i);
if(i < ns.length-1) {
var old = ns[i];
this.tpl.insertBefore(old, d);
this.el.dom.removeChild(old);
}else{
this.tpl.append(this.el.dom, d);
}
}
this.updateIndexes(startIndex, endIndex);
}


The problem is the condition if(i < ns-length - 1):
Instead of the last node being updated in case of a change, a new node is inserted at the end of the view.
The condition should be fixed to (i < ns.length).

jack.slocum
20 Jan 2007, 5:41 AM
Thanks, I put in the correction.