我正在使用jsTree jQuery插件,并希望在用户双击节点时执行代码。
我好像不能让它工作。我找到了一些关于ondblclk
事件的文档,但它不会触发。
browser.jstree(
{
plugins: ["themes", "json_data", "ui", "cookies"],
callback:
{
ondblclk: function (node, tree) {
if (!thisReportBrowserthis._isFoldersOnly) {
var f = node;
}
}
}
}
);
如何使用jstree__处理双击事件?
发布于 2010-09-10 07:59:18
事实证明我可以做到这一点:
jstree.bind("dblclick.jstree", function (event) {
var node = $(event.target).closest("li");
var data = node.data("jstree");
// Do my action
});
node
包含被单击的li
,data
包含包含我的信息的元数据。
发布于 2010-09-19 23:49:47
'dblclick.jstree‘在最新版本的jsTree 1.0中不存在。
节点的DoubleClick:
$("#yourtree").delegate("a","dblclick", function(e) {
var idn = $(this).parent().attr("id").split("_")[1];
alert(idn); //return NodeID
});
如果您只想要dblclicked节点,请插入此内容
if (this.className.indexOf('icon') == -1) { /* is the node clicked a leaf? */ }
发布于 2011-04-14 00:49:12
为我获取数据有点不同,但除此之外,GiddyUpHorsey的答案是正确的。下面是代码:
jstree.bind("dblclick.jstree", function (e, data) {
var node = $(e.target).closest("li");
var id = node[0].id; //id of the selected node
});
https://stackoverflow.com/questions/3674625
复制相似问题