Jstree
This article adds a node double-click event based on jstree 1.0-RC1.
Jstree is a jquery-based tree plug-in that supports drag-and-drop, copy, delete, shortcut keys, multiple selections, custom node icons, custom right-click menus, and cross-page save statuses, in short, I think it is basically there, and the most commendable thing is that it makes people feel not slow at all.
Jstree has a node selection event, that is
. BIND ("Select_node.jstree",Function(E, data ){// Alert (data. rslt. obj. ATTR ("ID") + ":" + data. rslt. obj. ATTR ("rel "));})
In fact, I think it is more like a nodeClickEvent, because it is triggered every time a node is clicked, regardless of whether the node has been selected.
Recently, a file management task needs to use the double-click event of a node. For example, double-click a node to open the editing page of the node.
Although there is a double-click event in jstree, It is not targeted at nodes, but is triggered in the area where you double-click the tree, such as any place.
DepartureNode double-click eventThe closest thing isNode selection eventTherefore, it is "different from others.
Analysis
This. get_container () is the Click Event of the node.
. Delegate ("","Click. jstree", $. Proxy (Function(Event) {event. preventdefault ();This. Select_node (event. currenttarget,True, Event );},This))
Similarly, I will insert a node double-click event here.
. Delegate ("","Dblclick. jstree", $. Proxy (Function(Event) {event. preventdefault ();This. Dblclick_node (event. currenttarget,True, Event );},This))
Then, I will implementDblclick_nodeMethod.
FindCode. However, "90%" is useless for double-clicking, such as processing multiple choice, multiple choice, and saving the selection result to cookies. ThereforeDblclick_nodeMethod implementation is much easier than select_node.
Dblclick_node:Function(OBJ, check, e) {OBJ =This. _ Get_node (OBJ );If(OBJ =-1 |! OBJ |! OBJ. Length ){Return false;}This. _ Callback ({"OBJ": OBJ });},
OK.
Example
Same as select_node
. BIND ("Dblclick_node.jstree",Function(E, data ){// Alert (data. rslt. obj. ATTR ("ID") + ":" + data. rslt. obj. ATTR ("rel "));})
Download transformed code
Jquery. jstree. js
By the way
Jstree and another plug-in jqueryValidateIt is not a matter of fire. When the two coexist, jstree can also construct a tree, but it cannot be expanded like a zombie. Mark one here and try to modify it later.