Home  >  Article  >  Web Front-end  >  JQery jstree large data volume problem solution_jquery

JQery jstree large data volume problem solution_jquery

WBOY
WBOYOriginal
2016-05-16 18:32:481332browse

Problem solution: The generated tree is loaded step by step, and there is a code for generating nodes in the open function:
Code

Copy code The code is as follows:

for (var i=0; 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);

  The problem lies in the TREE_OBJ.create function, which consumes a lot of performance. Change the code to the following:
Code
Copy the code The code is as follows:

var children= "";
for (var i=0; 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);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn