jstree-table
jstree-table copied to clipboard
set_id bug, and potential fix
Hi Adam,
Great library! Thanks!
I noticed that when I did a set_id operation in a jstree, two of jstreetable's columns were given the same id in the DOM!
Below please find the code section in question, and my potential fix.
Thanks again! Mark
// update id in children
// M.X. 10/24/2019
// Fix bug where two cells are given same id!
// Variable i was never given a chance to increment
// even though findDataCell was returning multiple elements.
/* orig
for (i = 0; i < oldNodes.length; i++)
{
findDataCell(table,oldNodes[i])
.attr(NODE_DATA_ATTR, obj.id)
.attr('id', TABLECELLID_PREFIX+obj.id+TABLECELLID_POSTFIX+(i+1))
.removeClass(TABLECELLID_PREFIX+old+TABLECELLID_POSTFIX)
.addClass(TABLECELLID_PREFIX+obj.id+TABLECELLID_POSTFIX);
}
*/
for (i = 0; i < oldNodes.length; i++)
{
var cells = findDataCell(table, oldNodes[i]);
cells.each(function (cellIndex)
{
$(this).attr(NODE_DATA_ATTR, obj.id);
$(this).attr('id', TABLECELLID_PREFIX + obj.id + TABLECELLID_POSTFIX + (cellIndex + 1));
$(this).removeClass(TABLECELLID_PREFIX + old + TABLECELLID_POSTFIX);
$(this).addClass(TABLECELLID_PREFIX + obj.id + TABLECELLID_POSTFIX);
});
}