jsTree Object has no method addBack

扶醉桌前 提交于 2019-12-12 11:23:17

问题


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);
});

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' 

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.


回答1:


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



来源:https://stackoverflow.com/questions/15057620/jstree-object-has-no-method-addback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!