JsTree 多树 cookie

发布于 2025-01-01 03:08:41 字数 1637 浏览 1 评论 0原文

大家好,我使用 jstree,并且在同一页面中有多个树。我有两个问题:

1)我想要 cookie 来区分每棵树中打开的节点。我尝试使用前缀实现此功能,但不幸的是:

"cookies" : { "cookie_options" : { "prefix" : "home" } },

不起作用,因为刷新后仅重新打开最后一个打开的节点。

2)我不希望能够创建新的根节点。我只想能够创建文件或将文件传输到我的根目录中。

我正在尝试使用:

"types" : {
            "types" : {
                // The default type
                "default" : {
                    "valid_children" : "none",
                    "icon" : {
                        "image" : "./file.png"
                    }
                },
                // The `folder` type
                "folder" : {
                    "valid_children" : [ "default", "folder", "file" ],
                    "icon" : {
                        "image" : "./folder.png"
                    }
                },
                // The `drive` nodes 
                "drive" : {
                    // can have files and folders inside, but NOT other `drive` nodes
                    "valid_children" : [ "default", "folder" ],
                    "icon" : {
                        "image" : "./root.png"
                    },
                    // those prevent the functions with the same name to be used on `drive` nodes
                    // internally the `before` event is used
                    "start_drag" : false,
                    "move_node" : false,
                    "delete_node" : false,
                    "remove" : false
                }
            }
        },

但我仍然能够将文件发布到我的根目录中。我是否应该在根目录上方创建另一个不带 rel=drive

  • 谢谢。

    Hello guys I use jstree and I have multiple tree in the same page. I have two problems:

    1) I want cookies in order to distinguish which nodes are open in each tree. I try to implement this functionality using prefix but unfortunately:

    "cookies" : { "cookie_options" : { "prefix" : "home" } },
    

    does not work since only the last opened node is re-opened after refresh.

    2) I do not want to be able to create new root nodes.I only want to be able to create files or transfer files into my root directory.

    I am trying to achieve that using:

    "types" : {
                "types" : {
                    // The default type
                    "default" : {
                        "valid_children" : "none",
                        "icon" : {
                            "image" : "./file.png"
                        }
                    },
                    // The `folder` type
                    "folder" : {
                        "valid_children" : [ "default", "folder", "file" ],
                        "icon" : {
                            "image" : "./folder.png"
                        }
                    },
                    // The `drive` nodes 
                    "drive" : {
                        // can have files and folders inside, but NOT other `drive` nodes
                        "valid_children" : [ "default", "folder" ],
                        "icon" : {
                            "image" : "./root.png"
                        },
                        // those prevent the functions with the same name to be used on `drive` nodes
                        // internally the `before` event is used
                        "start_drag" : false,
                        "move_node" : false,
                        "delete_node" : false,
                        "remove" : false
                    }
                }
            },
    

    but I am still able to post files into my root directory. Should I create another <li> without rel=drive above the root directory?

    Thanks.

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    ┾廆蒐ゝ 2025-01-08 03:08:41

    多棵树中cookie的解决方案:

    .
    .
    "cookies": {
      "save_selected": "node_selected_" + tree_id
      "save_opened": "node_opened_" + tree_id
    },
    .
    .
    

    没有“前缀”这样的选项。 “save_selected”和“save_opened”采用字符串或 false。通过提供不同的tree_id,您可以有效地为每棵树使用不同的cookie。

    The solution for cookies in multiple trees:

    .
    .
    "cookies": {
      "save_selected": "node_selected_" + tree_id
      "save_opened": "node_opened_" + tree_id
    },
    .
    .
    

    There is no such option as "prefix". "save_selected" and "save_opened" take either a string or false. By providing different tree_id you effectively use different cookies for each tree.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文