最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to listen to jsTree deselect event? - Stack Overflow

programmeradmin5浏览0评论

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?

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?

Share Improve this question edited Jul 23, 2012 at 9:03 Johnbabu Koppolu asked Jul 20, 2012 at 9:17 Johnbabu KoppoluJohnbabu Koppolu 3,2522 gold badges25 silver badges34 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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/mmeah/fyDE6/

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

发布评论

评论列表(0)

  1. 暂无评论