问题描述:
用jsTree从做了个动态树,可以通过多选配置内容,发现配置完成后,再次点击显示树,树的内容仍然是历史数据,而底层数据的确更新了,360浏览器有这个问题,chrome浏览器没有这个问题。
原因是jsTree将数据缓存在了客户端浏览器里,没有到后台取新的数据
解决办法:
上面链接给了两个办法:
1、JSTree 插件使用键“jstree”将树状态保存在浏览器的 localStorage 中。因此,在调用 jstree 之前,您应该从 localStorage 中删除该键,如下所示:
//Removes jstree cached state from localStorage
localStorage.removeItem('jstree');
$('#tree').jstree({
'core': {
data:{
'url':'getjstree'
}
}
});
这个对我不管用
2、设置数据缓存为false(‘cache’:false,),这个起作用了:)
$('#tree').jstree({
'core': {
data:{
'cache':false,
'url':'getjstree' // this is the url which will get the json data from the server
}
}});