【问题标题】:jsTree TYPE plugin events are ignoredjsTree TYPE 插件事件被忽略
【发布时间】:2014-01-31 18:42:59
【问题描述】:

我根本无法让 jsTree“类型”插件在任何容量下工作,并且在我可以检测到的任何地方都没有触发错误。

1.) 我参考了这个SO Question 来通过鼠标单击打开/关闭节点,但该函数永远不会被执行。

2.) 对于“类型”插件,jsTree Plugin Documentation 表示:

要设置节点的类型,您可以使用 set_type 或 提供类型属性 与节点的数据。

我怀疑这是设置问题,因为“类型”设置都不起作用,但“上下文菜单”插件确实起作用,所以看起来所有脚本都已到位,我为“类型”做错了

有没有其他人遇到过这个问题,或者有人知道我哪里出错了吗?

HTML

<div id="jstree"></div>
<script>
    $(function () {
        $('#jstree').jstree({
            "types" : {
                "types" : {
                    "series_type" : {
                        "icon" : {
                            "image" : "images/seriesnode.png"
                        }
                    },
                    "default" : {
                        "select_node" : function(e) {
                            console.info(e);
                            this.toggle_node(e);
                            return false;
                        }
                    }
                }
            },
            "plugins" : [ "types", "ui" , "contextmenu" ],
            "contextmenu": { "items": {} },
            "core" : {
                'data' : {
                    'url' : 'series_tree_data.php'
                }
            }
        });
    });
</script>

AJAX 调用返回的 JSON 数据:

[
    {   "id":"series_123120",
        "parent":"#",
        "text":"1945 - The Year That Changed The World",
        "type":"series_type",
        "state":{"opened":true}
    },
    {   "id":"title_2003150",
        "parent":"series_123120",
        "text":"Beginning of the End",
    },
    {   "id":"segment_3006200",
        "parent":"title_2003150",
        "text":"Full Program",
    },
    {   "id":"file_552973",
        "parent":"segment_3006200",
        "text":"1945_part_1.flv",
        "icon":false
    }
]

【问题讨论】:

    标签: jquery jstree


    【解决方案1】:

    从我在http://www.jstree.com/api/#/?f=$.jstree.defaults.types 的文档中看到的,没有提到“select_node”,所以这部分似乎根本不应该工作。我会检查你是否有最新的库。

    【讨论】:

    • 看起来就是这样....通常不是新版本的东西少了....但至少我可以停止挠头
    【解决方案2】:

    我在类型方面遇到了一些问题,这对我有用:

    $('#jstree').jstree({
                    "types":{
                       "key" : {
                           "icon": "Content/Images/skey.png"
                        },
                       "value": {
                           "icon": "Content/Images/sValue.png"
                       }
                    },
    

    您可能还想尝试将 a_attr: "rel": "series_type" 添加到您的数据中。

    祝你好运

    【讨论】:

    • 谢谢@amda ...我认为混淆在于大多数谷歌搜索返回的旧版本(并且相当普遍)版本,其中许多功能不再包含在最新版本中(我下载了) .似乎不再支持“类型”功能(或至少现在),Themeroller 也不支持。它实际上是我试图实现的 "select_node" : function(e) {},但无法启动它来拯救我的灵魂,哈哈。
    • @GDP - 是的,我也有类似的问题。新版本支持该类型,但不支持主题。你让它工作了吗?
    • @amda...我最终将一个事件绑定到我想要的点击处理...看来 Types 有巨大的潜力没有被利用...叹息
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-15
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 2014-08-27
    相关资源
    最近更新 更多