Hello,
I really have a strange problem. I am implementing an Web-App
that includes two jstree instances on one page. Both trees are
set up and work fine.
No I need to call refresh() on one these trees. The first one is found
and refreshed ok. But for the second one jstree(true) just returns false.
What could be the problem? I really do not have an idea where to start debugging.
Because the app is a little complex including iframes that invoke javascript
functions in the top document it is difficult to extract the code and build an
example.
Both trees use the same init-Code for setting them up. The second tree (#bookmark_list), that
cannot be found, is defined like this:
<div id="treeview"></div> <!-- The first treeview -->
...
<div id="bookmark_list" data-jstree-content="bookmark"></div> <!-- the second one -->
...
element_selector = 'div#bookmark_list';
...
var $element = jQuery(element_selector);
jstree_instance = $element.jstree({
'core' : {
"multiple" : false,
"animation" : 60,
'themes' : {
'dots': true,
'stripes': false
},
'data' : {
type: "POST",
'url' : dispatcher_url + '/PageJSTree/load_node/' + ticket,
'data' : function (node) {
var opened = [current_root_oid];
this.get_node(node, true).find('.jstree-open').each(function () { opened.push(
this.id); });
// content describes which tree will loaded
var jstree_content = $element.attr('data-jstree-content');
return {
"root_oid": current_root_oid,
"content": jstree_content,
"opened": opened
};
}
}
}
This works fine so far.
But after this I am not able to refresh this instance. I have tried many things like:
jstree_instance.refresh();
jQuery(element_selector).jstree(true).refresh();
but I get the error that "refresh is not a function".
For debugging I put in some console.log calls:
console.log('container_selector');
console.log(container_selector);
console.log("jQuery(container_selector)");
console.log(jQuery(container_selector));
console.log("jQuery(container_selector).jstree(true)");
console.log(jQuery(container_selector).jstree(true));
jQuery(container_selector).jstree(true).refresh();
And I get the output:
Does anybody have an idea what the problem could be?
Thanks
Gert