2012-04-08 190 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"); 
    }); 
})