【发布时间】:2011-04-25 14:25:42
【问题描述】:
$("#treeDiv").dblclick(function () {
this.rename(this.data.ui.hovered || this.data.ui.last_selected);
});
我正在研究 JSTree。我尝试了上面的代码来重命名树的节点。
treeDiv 是树的 div 的 ID。上面的代码不起作用。任何人都知道我在哪里做的错误,请告诉我。
【问题讨论】:
$("#treeDiv").dblclick(function () {
this.rename(this.data.ui.hovered || this.data.ui.last_selected);
});
我正在研究 JSTree。我尝试了上面的代码来重命名树的节点。
treeDiv 是树的 div 的 ID。上面的代码不起作用。任何人都知道我在哪里做的错误,请告诉我。
【问题讨论】:
在上面的代码中,这将指向自身,而不是 jstree 对象或 jquery 对象。
这是正确的形式:
$("#treeDiv")
.bind("dblclick.jstree", function (evnt) {
$(this).jstree('rename', evnt.target);
});
通常,当您没有真正的 jstree 对象(支持 .rename)时,您应该使用 $('#tree').jstree(command, arg) 并且还应该使用上面示例中的事件。
【讨论】: