Javascript 如何防止dojox/data/JsonRestStore上的缓存?
在使用REST存储更新dojo树的数据时,我必须更改项目的名称。缓存可以避免对树中已使用的项进行此更改。如何禁用缓存。 以下是代码的一部分:Javascript 如何防止dojox/data/JsonRestStore上的缓存?,javascript,dojo,jsonreststore,Javascript,Dojo,Jsonreststore,在使用REST存储更新dojo树的数据时,我必须更改项目的名称。缓存可以避免对树中已使用的项进行此更改。如何禁用缓存。 以下是代码的一部分: var prod= { store: null, model: null, tree: null, init: function() { this.store = new dojox.data.JsonRestStore({ target: 'jtf-products-REST.php', labelAttribu
var prod= {
store: null,
model: null,
tree: null,
init: function() {
this.store = new dojox.data.JsonRestStore({
target: 'jtf-products-REST.php',
labelAttribute: "name"
});
this.model = new dijit.tree.ForestStoreModel({
store: this.store,
deferItemLoadingUntilExpand: true,
rootId: "products",
rootLabel: "Products",
query: {},
childrenAttrs: ['children']
});
}};
//...
dojo.addOnLoad(function() {
prod.init();
prod.tree = new dijit.Tree({
model: prod.model,
dndController: dijit.tree.dndSource,
checkAcceptance:never,
persist: false
}, 'products_tree');
prod.tree.startup();
/...
function filterProducts() {
if (keyword = prompt("input")) {
dijit.byId('products_tree').destroy(true);
dojo.xhrPost({
url: 'jtf-products.php',
content: {
key: keyword,
type:'products'
},
//preventCache: true,
load: function(response) {
dojo.byId('numberofproducts').innerHTML=response+" products";
tree=prod.tree
tree._itemNodesMap = {};
tree.rootNode.state = "UNCHECKED";
tree.model.root.children = null;
if (tree.rootNode) {
tree.rootNode.destroyRecursive();
}
tree._load();
//...
谢谢。试试这个:
this.store=new dojox.data.JsonRestStore({
目标:'jtf products REST.php?_dc='+new Date().getTime(),
我不确定。据我所知,您可能会在请求(xhrPost)中设置查询选项:{cache:false}。还请注意,dojo2不适用于xhrPost,它是{preventCache:true},但这不是问题。问题出在从服务器请求的REST存储中。在dojox/data/JsonRestStore文档中,我们可以找到“JsonRestStore将从服务器本地检索的对象缓存在内存中。”但没有说明如何禁用它。