如何防止 dojox/data/JsonRestStore 上的缓存?
How to prevent cache on dojox/data/JsonRestStore?
在使用 REST 存储更新 dojo 树的数据时,我必须更改项目的名称。缓存正在避免对树中已使用的项目进行此更改。如何禁用缓存。
这是代码的一部分:
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({
target: 'jtf-products-REST.php?_dc=' + new Date().getTime(),
在使用 REST 存储更新 dojo 树的数据时,我必须更改项目的名称。缓存正在避免对树中已使用的项目进行此更改。如何禁用缓存。 这是代码的一部分:
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({
target: 'jtf-products-REST.php?_dc=' + new Date().getTime(),