how to listen to jsTree deselect event?

[亡魂溺海] 提交于 2019-12-23 17:25:31

问题


I am trying to listen to deselect event of JsTree like below

$(document).ready(function() {  
    var jData = [{
        "data": {
            "attr": {
                "title": "A node"               
            },
            "title" : "A node"
            },

            "children": [{
                "data": {
                    "title": "child"
                },
                "children": [{
                    "data": {
                        "title": "Grand Child"
                    }
                }]
            }]
        }];

        var myTree = $("#demo1").jstree({
            "json_data": {
                "data": jData
            },          
            "plugins": ["json_data", "ui", "themeroller"]
        });

        $(myTree).bind("select_node.jstree", function(evt, data) {
            console.log("selected!");
        });
        $(myTree).bind("deselect_node.jstree", function(evt, data) {
            console.log("deselected!");
        });

    });

According to the documentation here, 'deselect_node' triggers an event, but nothing seems to happen when I do like above. I am able to listen to select event though.

How to listen to jsTree deselect event?


回答1:


Works for me, perhaps the missing semi-colon is breaking in some browsers.

Here is re-write of your example as a fiddle: http://jsfiddle.net/mmeah/fyDE6/

Updated: http://jsfiddle.net/mmeah/fyDE6/2/



来源:https://stackoverflow.com/questions/11576444/how-to-listen-to-jstree-deselect-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!