似乎
Tree.js
不允许您设置cookie的属性。所以我不得不重写
_saveState()
方法
Tree
:
var treeControl = new dijit.Tree({
model: treeModel,
showRoot: false,
openOnClick: false,
cookieName: "OrganizationUnitTreeState",
_saveState: function(){
// summary:
// Create and save a cookie with the currently expanded nodes identifiers
// Overre the default saveState function, so we can set the cookie path
if(!this.persist){
return;
}
var ary = [];
for(var id in this._openedItemIds){
ary.push(id);
}
dojo.cookie(this.cookieName, ary.join(","), {expires:365, path:"/"});
},
/* Many more methods */
});
这是最后一行代码。这个
dojo.cookie()
获取键/值对的列表,这些键/值对将转换为cookie属性,因此如果您希望设置任何其他属性,请执行以下操作。