2012-04-08 8 views
0

create_node 함수를 사용하여 트리에 노드를 추가 할 때 jsTree를 사용하여 https://github.com/vakata/jstree/blob/v.1.0/dist/jstree.js#L3549처럼 콜백 함수를 추가하려고합니다.jsTree create_node 콜백 함수가 작동하지 않습니다.

그러나, 여기에 예시 된 바와 같이, 실행하지 않는 것 - Add Root Item을 클릭 할 때 (적어도에서 "안녕하세요"라고 console.log() 기대)>http://jsfiddle.net/thapar/e3nMg/.

내가 뭘 잘못하고 있을지 모르겠다.

답변

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"); 
    }); 
}) 
관련 문제