【问题标题】:JS Tree Context Menu PluginJS 树上下文菜单插件
【发布时间】:2018-09-13 14:56:17
【问题描述】:

最初我的 JS 树是

<div id="jstree">
<ul>
   <li>Name=
      <ul>
         <li>Deepanshu</li>
      </ul>
   </li>
</ul>
</div>

如果我将 Deepanshu 中的名称字段编辑为某个数值,则在单击提交按钮时,会发生一个 rest api 调用(它基本上返回相同的 html 并弹出一个无效值)。在 rest 调用返回的 html 中,js 树与调用 rest 之前相同。现在,如果我右键单击节点名称或节点 Deepanshu 以编辑、删除、创建新节点等。上下文菜单不会出现。

我使用的Javascript是

<script>
   $(function () {
    $('#jstree').jstree({
     "core" : {
         "check_callback" : true
     },
     "plugins" : [
         "state", "types", "contextmenu"
      ]
   });

   $('#jstree').on('changed_jstree', function (e, data) {
      console.log(data.selected);
   });
});
</script>

如果有人能帮我解决这个问题,那就太好了。

【问题讨论】:

  • 请编辑帖子以包含您正在处理的 html 和 javascript。

标签: javascript html jstree


【解决方案1】:

检查您的 html 文件。html 文件的示例用法

<div id="plugins2" class="demo plugin-demo">
<ul>
    <li data-jstree='{"opened":true}'>Root node
        <ul>
            <li>Context click me</li>
        </ul>
    </li>
</ul>

之后,创建您的 JSTree

<script>
$(function () {
    $("#plugins2")
        .jstree({
            "core" : {
                'force_text' : true,
                "check_callback" : true
            },
            "plugins" : [ "contextmenu" ]
        });
});
</script>

记住;当你使用 JSTree 时要小心 id 字段

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2023-03-18
    • 2017-11-10
    • 2011-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多