[dojo] save dijit.layout.TabContainer selected tab
七月 31, 2011
用繼承的方式果然好搞很多, 直接攔截事件開始處理…
又可以重複使用
dojo.declare("dijit.MyTabContainer" , [ dijit.layout.TabContainer ] ,
{
postCreate : function() {
var childId = dojo.cookie(this.id);
var tabContainerId = this.id;
if (childId !== undefined) {
// use dojo.addOnLoad to avoid tab content not ready.
dojo.addOnLoad(function() {
var selectedChild = dijit.byId(childId);
if (selectedChild !== undefined) {
dijit.byId(tabContainerId).selectChild(selectedChild);
}
});
}
this.inherited(arguments);
},
selectChild : function(selectedTab) {
// save selected tab id
if (selectedTab !== undefined) {
dojo.cookie(this.id, selectedTab.id , { expires : 365 });
}
this.inherited(arguments);
}
});
尚無迴響
