JQery jstree big data volume solution

Source: Internet
Author: User

Problem description: Jquery uses jstree to dynamically generate a tree. If there are more than 500 directories under a node, IE will prompt whether JavaScript scripts are allowed to run and the contents are not fully loaded, it only loads about 300.

Solution: The generated tree is loaded step by step. There is a code for generating nodes in the open function:

Code
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 );

The problem arises from the TREE_OBJ.create function, which consumes a lot of performance. The code is changed to the following:

Var children = "";
For (var I = 0; I <data. length; I ++)
{
Children + = TREE_OBJ.parseJSON (data [I]);
}
If (children! = "")
Certificate (node).children('ul'0000.html (children );

Var firstChild = TREE_OBJ.children (NODE) [0];
If ($ (firstChild). attr ('id') =-1)
TREE_OBJ.remove (firstChild );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.