I have a button that reloads (resends an AJAX request) the jsTree once is clicked.
Here is a sample configuration code I have:
treeContainer.bind("loaded.jstree", function () {
alert("the tree is loaded");
}).jstree(config);
The problem I experience is that I do not have the alert (wrapped in a callback function) displayed once the 'reload' button is clicked the 2nd, 3rd, etc. times. Am I using the wrong jstree status event?
To summarize, I want a jsTree callback function to be executed each time I click the 'reload' button.
I am currently using jsTree 1.0-rc1 (rev. 191).
Destroying the tree before building the new one works as well.
treeContainer.jstree("destroy");
treeContainer.bind("loaded.jstree", function () {
alert("the tree is loaded");
}).jstree(config);
add this to the core:
reopen : function () {
var _this = this;
if(this.data.core.to_open.length) {
$.each(this.data.core.to_open, function (i, val) {
_this.open_node(val, false, true);
});
}
this.__callback({});
this.reopened();
},
note that only this.reopened is added to the allready existing reopen-method. now create the reopened-method:
reopened : function () {
this.__callback();
},
now bind the new reopened-method to your tree-selector
}).bind("reopened.jstree", function (e,data) {
alert("i am refreshed...");
});
be carefull, because this alert-message will also be called when the tree is done loading. It is anyhow better, since you now have a way to have a callback when the tree is refreshed!
hope this helps you all!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With