jsTree对象没有方法addBack [英] jsTree Object has no method addBack

查看:76
本文介绍了jsTree对象没有方法addBack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我对jsTree的实例化代码。

This is my instantiation code for the jsTree.

$("#folder_tree").jstree({
    "themes" : {
        "theme" : "default",
        "dots" : true,
        "icons" : true
    },
    "json_data" : {
        "ajax" : {
            "url" : "/portal/folders",
            "data" : function(n) {
                if ($(n[0]).find("a").attr("id")) {
                    console.log($(n[0]).find("a").attr("id").split('_')[1]);
                    return {
                        "id" : $(n[0]).find("a").attr("id").split('_')[1]
                    };
                }
                return { "id" : "0" };
            }
        }
    },
    "plugins" : [ "themes", "json_data", "ui", "contextmenu", "dnd", "search", "crrm" ]
}).bind("select_node.jstree", function(e,data) {
    console.log(data.rslt.obj.context.id);
});

它在第一次加载(0大小写)时正确加载数据,但是当我点击时扩展任何文件夹,它给我错误:

It loads the data correctly on the first load (the 0 case), but then when I click to expand any of the folders, it is giving me the error:

Uncaught TypeError: Object [object Object] has no method 'addBack' 

即使扩展节点的正确id被记录到控制台并且ajax请求是正确地对服务器。另请注意,我必须使用相当可怕的kludge来查找元素的id,因为在尝试访问时,记录的代码只会产生错误(我使用与文档相同的jsTree版本) n.attr( ID)。另外,在下绑定(select_node... 我必须使用未记录的函数再次查找id。经过数小时的故障排除后,我仍然感到困惑,但有些东西显然无法正常运行。

Even though the correct id of the expanded node is being logged to the console and the ajax request is being made to the server correctly. Notice also that I have to use a fairly horrific kludge to find the id of the element due to the fact that the documented code produces nothing but errors for me (and I am using the same version of jsTree as the documentation) when trying to access n.attr("id"). Plus, under bind("select_node"... I have to use a non-documented function to find the id again. After hours of troubleshooting, I'm still completely baffled, but something is clearly not operating correctly.

推荐答案

确保使用的是jQuery 1.8或更高版本。直到那时才添加addBack

Make sure you are using jQuery 1.8 or later. addBack wasn't added until then.

这篇关于jsTree对象没有方法addBack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆