2012-04-08 186 views

回答

1

根据http://www.jstree.com/documentation/core的文档,它看起来像.create_node函数的“回调”参数在内部使用。它表示,你应该倾听该事件。你可以这样做(假设你使用相同的代码在你的JSFiddle帖子:

$('.colors').bind('create_node.jstree', function (e, data) { 
    console.log('hi', data.rslt.obj); 
}); 

3

jstree第3版,还有一个create_node事件:

“触发时一个节点创建“:

http://www.jstree.com/api/#/?q=.jstree%20Event&f=create_node.jstree

$(function() { 
    var $root = $('#jstree').jstree({ 
     "core" : { 
      check_callback : true 
     }, 
     "themes" : {}, 
     "ui" : {}, 
     "plugins" : [ "dnd", "state","themes", "html_data", "ccrm", "ui" ], 

    });  

    $('#jstree').on('create_node.jstree', function(e, data) { 
     console.log('hi', data); 
    }); 

    $('#add_root').click(function() { 
     $root.jstree(true).create_node($root, "sub4"); 
    }); 
})