About the new child node tree in the leaf node cannot asynchronously refresh the problem

Source: Internet
Author: User

When there are no leaf nodes under the root node, a new child node is added and the node is refreshed without success (the node is not refreshed, but has been successfully inserted)


Because the Ztree.reasyncchildnodes method is only valid for the root node, which is accurate when the Isparent property of the node is true, when a new node is added under the leaf node, the Isparent property of the original leaf node is false, so it does not trigger Reasyncchil Dnodes This method, we need to change the Isparent property of the node to true before triggering the method to call.


New node code for generic root node:

var ztree=$.fn.ztree.getztreeobj ("Restree");
var node=ztree.getselectednodes ();
var pnode=node[0].getparentnode ();
Ztree.reasyncchildnodes (Pnode, "refresh", false);


New child node code for leaf node:

var ztree=$.fn.ztree.getztreeobj ("Restree");
var node=ztree.getselectednodes ();
var node1=node[0];
Node1.isparent = true;//turns the attribute to true so that the node is considered to be the root node
Ztree.reasyncchildnodes (Node1, "refresh", false);


This makes it possible to successfully implement an asynchronous flush.

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.