2015-07-13 66 views
0

我从Web服务(按需)绑定我的jStree并且工作正常,现在我想使用上下文菜单插件重命名节点,上下文菜单显示为预计只有一个重命名的项目,但点击它的节点不会变得可编辑无法使用contextmenu插件重命名jsTree中的节点

我初始化jsTree的代码如下。

我已经设置了“check_callback”属性为true,并且还补充说,应该允许重命名树节点的规则,

我已经在控制台检查(Chrome开发者选项),并证实了“行动“方法正在打中,我也得到当前节点的数据,但.edit方法调用后没有任何反应,

我相信.edit方法是使节点可编辑,编辑完成后,我应该获取rename_node事件。但是,这种情况不会发生

请纠正我,如果我有同样的

jQuery("#divTree").on("select_node.jstree", function (e, data) { 
    jQuery.AreaManagementInfo.CurrentlySelectedArea = data.node; 
}).on('rename_node.jstree ', function (obj, val) { 
    alert('rename '); 
}).jstree({ 
    'plugins': ['contextmenu'], 
    'rules': { 
     "renameable": "all", 
     "multiple" : false 
    }, 
    "contextmenu": { 
     "items": function ($node) { 
      return { 
       "Rename": { 
        "label": "Rename", 
        "action": function (data) { 
         var inst = $.jstree.reference(data.reference), 
         obj = inst.get_node(data.reference); 
         inst.edit(obj); 
        } 
       } 
      }; 
     } 
    }, 
    'core': { 
     'data': { 
      'type': 'POST', 
      'cache': true, 
      'contentType': 'application/json', 
      'url': Url, 
      'check_callback': true, 
      'themes': { "stripes": true }, 
      'data': function (node) { 
       var parentId = 0; 
       if (node.id != "#") { 
        parentId = node.data.AreaId; 
       } 
       return JSON.stringify({ basicParam: basicParam, parentId: parentId }); 
      }, 
      'success': function (data) { 
       if (data.d != null) { 
        if (data.d != "") { 
         var length = data.d.length - 1; 
        } 
       } 
       return data.d; 
      }, 
      'error': function (request, error) { 
       jQuery("#divTree").addClass("hide"); 
      } 

     } 
    } 
}); 
+0

我相信我在jsTree中设置规则的方式有些问题,正如我所提到的“多重”:false“,但它仍然允许我选择多个节点(ctrl + click允许多个节点选择) –

+0

我也无法设置jsTree的主题是否发生,因为主题没有正确添加.. ?? –

回答

0

check_callback错误的认识不应该是里面data,它应该是core直接子 - 纠正和所有将工作精细。事实上 - 仔细阅读文档 - 您在core.data中放置了很多选项,它们不属于那里,应该直接在core之内。