Jstree is a tree plug-in based on jquery, support drag-and-drop, copy, delete, shortcut, multiple selection, custom node icon, custom right-click menu, cross page save state, etc., anyway, I think of it basically have, and the most commendable is that it makes people feel not slow oh.
Jstree has node selection events, i.e.
. Bind ("Select_node.jstree", function (E, data) {
Alert (data.rslt.obj.attr ("id") + ":" + data.rslt.obj.attr ("rel"));
})
Actually I think it's more like a node Click event, because it triggers every time the node is clicked, regardless of whether the node was previously selected.
Recently do a file management Dongdong, need to use the node of the double-click event, such as double-click a node to open the node's edit page.
Jstree Although there is a double-click event, but not for the node, but you double-click the area of the tree will trigger, as shown in any one place.
The closest thing to a node-double-clicked event is the node-selection event, which is "divert".
Analysis
After line No. 833 This.get_container () is the node's Click event
. Delegate ("A", "Click.jstree", $.proxy (function (event) {
Event.preventdefault ();
This.select_node (Event.currenttarget, True, event);
}, this))
Again I'm here insert node double-click event
. Delegate ("A", "Dblclick.jstree", $.proxy (function (event) {
Event.preventdefault ();
This.dblclick_node (Event.currenttarget, True, event);
}, this))
Then, I can realize the Dblclick_node method.
It is more complicated to find Select_node code on line No. 928. But inside 90% is no use for double clicks, such as processing radio, multiple selection, saving selection results to cookies and so on. Therefore, the implementation of Dblclick_node method is much simpler 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, that's it.
Use examples
Same as Select_node usage.
. Bind ("Dblclick_node.jstree", function (E, data) {
Alert (data.rslt.obj.attr ("id") + ":" + data.rslt.obj.attr ("rel"));
})
Modified code Download/201007/yuanma/jquery.jstree.rar
Oh, by the way.
Jstree with another plug-in jquery validate is incompatible, when both coexist, jstree although can also build trees out, but such as zombies generally can not unfold. Mark one here and try to revise it later.
Author: Bruce (art world of programming)