I have a jstree. on load of the page the jstree populates fine from the server as it make a fresh call to server, but after that whenever I refresh the page it will always take the data from cache and not make a call to server , thereby always taking the old data to populate. I am using jstree 3.0.2 version. following is the code which generated the jstree on load of the page .
$('#tree').jstree({
'core': {
data:{
'url':'getjstree' // this is the url which will get the json data from the server
}
}});
how do we solve this to get fresh data on each call, one solution which I earlier thought of using is the javascript code to hard refresh by calling
location.reload(true);
but that did refresh the json data but went into recursive call and thereby hanging the page. Please help how can we solve this issue.
JSTree plugin saves tree state in browser's localStorage with key "jstree". So before calling jstree you should erase that key from localStorage, like this:
//Removes jstree cached state from localStorage
localStorage.removeItem('jstree');
$('#tree').jstree({
'core': {
data:{
'url':'getjstree'
}
}
});
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