开发者

Jstree : dblclick binding parameter data is undefined

开发者 https://www.devze.com 2023-03-06 13:48 出处:网络
I try to use good lib jstree but i have some strange problem with dblclick binding. Here is my code $(\"#basic_html\").jstree({

I try to use good lib jstree but i have some strange problem with dblclick binding. Here is my code

$("#basic_html").jstree({
    themes: {
        url: "http://mywork/shinframework/shinfw/themes/redmond/css/jstree/default/style.css"开发者_运维百科
    },
    "plugins" : ["themes","html_data","ui","crrm","hotkeys", "core"],
});

$("#basic_html").bind("dblclick.jstree", function (e, data) {
    alert(e);
    alert(data);
});

When this code runs and i make dblclick for some node i can see 2 alerts. The first is object -right, the second is undefined - BUT i want receive data information.

Please, if some specialist solve this problem give me right way for correct use dblclick and receive "data" information about node who is i clicked.

Thanks


I recommend this approach . . .

$("#basic_html li").live("dblclick", function (data) {
   //this object is jsTree node that was double clicked
   ...
});

First, you usually only need to know if the li was clicked so monitoring the event on the li will give you everything you need. Secondly, use live or delegate for the event binding so you can manipulate the tree without breaking the event.

Once you have the node that was double clicked (the this object) you can then use the built-in functions like this . . .

if (!jsAll.is_selected(this)) { return false; } //cancel operation if dbl-clicked node not selected

Where . . .

jsAll = $.jstree._reference("basic_html")


$("#basic_html").bind("dblclick.jstree", function (event) {
    var node = $(event.target).closest("li");//that was the node you double click
});

that's the code you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消