Jstree : dblclick binding parameter data is undefined

后端 未结 2 1436
滥情空心
滥情空心 2021-01-20 03:09

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

$(\"#basic_html\").jstree({
    themes: {
           


        
相关标签:
2条回答
  • 2021-01-20 03:22
    $("#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 讨论(0)
  • 2021-01-20 03:33

    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")
    
    0 讨论(0)
提交回复
热议问题