Bootstrap-treeview Custom Double-click event Implementation Method _javascript tips

Source: Internet
Author: User

Bootstrap-treeview is a very cool effect based on the bootstrap jquery multilevel list tree plug-ins. The jquery plugin is based on Twitter Bootstrap, showing some inherited tree structures in simple and elegant ways, such as view trees, list trees, and so on. But somehow this plugin does not have its own double-click event.
After several tests, use method $ (' #tree '). DblClick (function () {}) and method $ (' #tree '). On (' DblClick ', function () {}) does not work! Puzzled by the solution. Finally, the rescue of the great God, the problem solved, but it seems not very elegant but eventually can be finished.

The solution uses the Bootstrap-treeview two event "nodeselected" and "nodeunselected". If double-clicking on a node in the TreeView will trigger the selected event and uncheck the event, Calculating the time interval between these two times can simulate the effect of a double-click event. Double-click an event each time the left mouse button interval, artificial operation 300 milliseconds enough.

The specific code is as follows:

<! DOCTYPE html>  

Coarse filter Explanation:

The most important global variable:lastselectednodeid,lastselectednodeid

The most important method:clicknode ()

This method is used primarily to determine whether the target of the selected event and the unchecked event action is one and whether the time interval is small enough. The customer is trying to trigger a double-click event that meets both of these criteria. You can then customize the business logic in the function custombusiness.

If you want to further study, you can click here to learn, and then attach two wonderful topics: Bootstrap Learning Tutorials Bootstrap Practical course

The above is the detailed content of this article, I hope to help you learn.

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.