Fixed the bug in adding subnodes to jquery. treeview.

Source: Internet
Author: User

1. The reason for the fix is that the treeview control is used in an android project (a token was originally implemented through the native api of android .). Originally, there were many excellent tree controls in js plug-ins, such as the famous ztree in China and the built-in tree of various ui controls. However, the simplest and easiest way to use data is to use the most classic jquery. treeview. And the animation effect is also good, I just took a fancy to its light, the animation effect is good, but also relatively easy to use .. (Other trees have not been touched yet ..)., So we use it. 2. The method to add a subnode to jquery. treeview during the fix process is View Code, but this method has a serious problem, that is, the added node must only be li. If a child node is inserted to a node without a child node, the expand button of the node does not exist, that is, the parent event is not bound .. As a result, it was useless to write several hack statements based on this idea, so I went to the source code .. Fortunately, there are not many codes of great gods. Although there are still several distances from the Earth to the Moon to understand the codes of great gods at the current level, but fortunately there are not many codes of great gods, and we can also find them using ctrl + F. Add a few lines of code here ..

Var branch = $ ("<li> <span> child1 </span> </li> "). appendTo (parentLi); $ ("# tree "). treeview ({add: branch });
A successful outbreak of character!

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.