时间:2021-07-01 10:21:17 帮助过:3人阅读
for (var i=0; i<data.length; i++)
{
var n = TREE_OBJ.create(data[i], $(NODE));
if (onaddnode) onaddnode(n);
}
var firstChild = TREE_OBJ.children(NODE)[0];
if ($(firstChild).attr('id')==-1)
TREE_OBJ.remove(firstChild);
问题就出 TREE_OBJ.create函数上,这个函数很消耗性能。代码改成如下:
代码
代码如下:
var children="";
for (var i=0; i<data.length; i++)
{
children += TREE_OBJ.parseJSON(data[i]);
}
if (children != "")
$(NODE).children('ul').html(children);
var firstChild = TREE_OBJ.children(NODE)[0];
if ($(firstChild).attr('id')==-1)
TREE_OBJ.remove(firstChild);