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:
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.