2011-05-05 143 views
0

我使用jstree與crrm和json_data插件。當我嘗試調用節點上的重命名函數時出現錯誤obj.trigger不是函數。jsTree重命名不起作用

我的代碼:

//definiton of tree 
    $('selector').jstree({ 
     //config for tree themes plugin 
     'themes' : { 
     'theme' : 'classic', 
     'dots' : true, 
     'icons' : true 
     }, 
     //config for tree json_data plugin 
     json_data : { 
     ajax : { 
      url: '?', 
      type: 'POST', 
      dataType: 'json', 
      beforeSend: function(xhr, s){ 
      xhr.setRequestHeader("Accept", "text/x-json"); 

      }, 
      context: this, 
      data: $.proxy(this,'_generateTreeJSONData'), 
      success: $.proxy(this,'_onTreeLoad'), 
      error: $.proxy(this,'_onTreeError') 
     } 
     }, 
     //config for tree drag and drop plugin 
     dnd:{ 
     drop_finish: $.proxy(this,'_onTreeDropFinish'), 
     drag_finish: $.proxy(this,'_onTreeDragFinish'), 
     drop_check: $.proxy(this,'_onTreeDropCheck'), 
     drag_check: $.proxy(this,'_onTreeDragCheck'), 
     drop_target: false, 
     drag_target: false 
     }, 
     //config for tree creating renaming removing moving (crrm) plugin 
     crrm:{ 
     move:{ 
      check_move: $.proxy(this,'_onTreeMoveCheck') 
     } 
     }, 
     plugins : ['themes','json_data','ui','dnd','crrm','contextmenu'] 
    }); 

    //conect to click of tree node 
    $(".ep-acb-tree a").live("click", $.proxy(this,'_onClickTreeNode')); 

    _onClickTreeNode: function(evt){ 
     $('selector').jstree('rename',evt.currentTarget); 
    }, 

這僅僅是我的代碼,但拖放和其他一切工作正常的一部分。

感謝您的幫助。 本

回答

0

您是否嘗試過綁定到rename_node像這樣:

.bind("rename_node.jstree", function (node, ref) { 
// Your code goes here.... 
}); 
+0

是的,我想這一點,但我的問題是,我無法打開編輯模式。 您的解決方案將綁定到重命名完成後觸發的事件,我猜。 我雖然嘗試了contextmenu插件,當我在菜單中單擊重命名時,我得到相同的錯誤。 – Ben 2011-05-06 06:59:49

+0

對不起,對於最近的回覆,但你有沒有嘗試用代碼中的「rename_node」代替「rename」?因此,而不是$('selector')。jstree('rename',...),試試$('selector')。jstree('rename_node',...); – 2011-05-10 04:09:09