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 pletely baffled, but something is clearly not operating correctly.
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 pletely baffled, but something is clearly not operating correctly.
-
4
Are you using jQuery 1.8 or later?
addBack
wasn't added until then. – cdmckay Commented Feb 24, 2013 at 22:51 - I added it as an answer. – cdmckay Commented Feb 25, 2013 at 2:03
1 Answer
Reset to default 12Make sure you are using jQuery 1.8 or later. addBack
wasn't added until then.