[Xsltforms-support] setindex error
Brought to you by:
alain-couthures
From: Stephen C. <ste...@gm...> - 2012-01-05 23:03:36
|
Hi Alain, Further to my email yesterday regarding issue with setindex failing to work correctly. I found that the problem is in the following routine. XsltForms_repeat.prototype.setIndex = function(index) { if (this.index !== index) { var node = this.nodes[index - 1]; if (node) { XsltForms_globals.openAction(); this.index = index; this.element.node = node; XsltForms_globals.addChange(this); XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getMeta(node.ownerDocument.documentElement, "model")).xfElement); XsltForms_globals.closeAction(); } } }; At the time this is called the nodes array has the old set of nodes (without the new one just added via xf:insert) so it will never reset if you are making it to the last node Changing it to the following seems to fix the issue XsltForms_repeat.prototype.setIndex = function(index) { if (this.index !== index) { this.index = index; var node = this.nodes[index - 1]; if (node) { XsltForms_globals.openAction(); //this.index = index; this.element.node = node; XsltForms_globals.addChange(this); XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getMeta(node.ownerDocument.documentElement, "model")).xfElement); XsltForms_globals.closeAction(); } } }; Not sure if you might need to add further checks e.g. XsltForms_repeat.prototype.setIndex = function(index) { if (this.index !== index) { this.index = index; if (this.index < this.nodes.length && this.nodes[index-1] ) { XsltForms_globals.openAction(); this.element.node = this.nodes[index-1]; XsltForms_globals.addChange(this); XsltForms_globals.addChange(document.getElementById(XsltForms_browser.getMeta(node.ownerDocument.documentElement, "model")).xfElement); XsltForms_globals.closeAction(); } } }; Regards Steve Cameron |