2017-05-10 4 views
0

以下は私が使用しているコードです。ノードが削除されると、delete_node.jstreeは起動しません。jstree:ノードイベントが削除されていません

 $('#tree-container').jstree({ 
    'plugins' : ['contextmenu'], 
    "check_callback" : true, 
    'core' : { 
     'data' : { 
      "url" : sTreeUrl + "?operation=gettree", 
      "dataType" : "json" , 
      'data' : function (node) { 
        return { 'parent' : node.id, 'tenantid' : tenantid }; 
       } 
     } 
    } 
    }); 
    $('#tree-container').on("delete_node.jstree", function (e, data) { 
     alert("s"); 
    }); 

これを修正するにはどうすればよいですか?

答えて

0

ほとんどの場合、'check_callback': truecoreプロパティの下に置く必要があります。デモを確認する - Fiddle Demo

$('#tree-container').jstree({ 
    'plugins' : ['contextmenu'],  
    'core' : { 
     'check_callback' : true, 
     ... 
    } 
}); 
0

their exampleによると、あなたはそうのようなjstree()インスタンス化する前に、イベントの委任をチェーン:

$('#tree-container').on("delete_node.jstree", function (e, data) { // listen for the event 
    alert("s"); 
}).jstree({ //create the instance 
    'plugins' : ['contextmenu'], 
    "check_callback" : true, 
    'core' : { 
     'data' : { 
      "url" : sTreeUrl + "?operation=gettree", 
      "dataType" : "json" , 
      'data' : function (node) { 
        return { 'parent' : node.id, 'tenantid' : tenantid }; 
       } 
     } 
    } 
}); 

私はこれをテストしていませんでしたし、自分自身をそれを使用していないが、それは役立つかもしれません。あなたはイベントが登録される前にjstreeをインスタンス化しています。これは、イベントのリスニング方法に応じて問題を引き起こす可能性があります(バージョンを持たないインスタンスを作成するときにフックを追加する可能性があります)。

関連する問題