Johnbabu Koppolu
Johnbabu Koppolu

Reputation: 3252

how to listen to jsTree deselect event?

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?

Upvotes: 3

Views: 8716

Answers (1)

MMeah
MMeah

Reputation: 1042

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/

Upvotes: 4

Related Questions