Reputation: 725
I get "Uncaught TypeError: Cannot read property 'obj' of undefined" when I clicked a jsTree node on my website.
Upon node click, the jsTree should use a key to retrieve a value, save it to a form, and submit the form. This is how "attr" in my JSON is defined:
"attr":{"href":"/animal/mammal/dog"}
This is how the node is bound:
$("#divCategoryTree")
.jstree(config_obj)
.bind("select_node.jstree", function(e, data) {
var href = data.rslt.obj.attr("href");
$("#hdCategoryPath").val(href);
$("#searchForm").submit();
e.preventDefault();
});
I have to confess, I am not entirely sure about what data.rslt.obj.attr
does, but it seems like a standard practice in online examples. I think it goes to the object's attr
field and uses href
as the key to retrieve its respective value. If anyone can point me to its documentation, I will be very grateful.
Upvotes: 1
Views: 1694
Reputation: 5061
To get href
of clicked node use:
data.event.currentTarget.href
like here: Fiddle
Upvotes: 1