I'm trying to tidy up my code a bit, therefore one step I wanted to do is to transform my declarative markup from my navigation menubar into a programmatic one. I simply wanted to extend the class of dijit/MenuBar and add my functions in there. This is what it looks like so far:
define([ "util/debugger", "dojo/_base/declare", "dojo/_base/lang", "dojo/on",
"dojo/ready", "dijit/MenuBar", "dijit/PopupMenuBarItem",
"dijit/MenuItem", "dijit/DropDownMenu" ], function(debug, declare,
lang, on, ready, MenuBar, PopupMenuBarItem, MenuItem, DropDownMenu) {
return declare("navMenu", [ MenuBar ], {
constructor : function(kwArgs) {
debug.log("constructor called", "navMenu.constructor()", 1);
lang.mixin(this, kwArgs);
/* Ansicht */
var subMenuAnsicht = new DropDownMenu({});
var item_showFilterBar = new MenuItem({
label : "Filterleiste anzeigen"
});
subMenuAnsicht.addChild(item_showFilterBar);
// [...]
var test = new PopupMenuBarItem({
label : "Ansicht",
popup : subMenuAnsicht
});
//---------
this.addChild(test); // <==== this is where dojo says "c is null"
//---------
/* Hilfe */
var subMenuHelp = new DropDownMenu({});
var item_showVersion = new MenuItem({
label : "Versionsinfo"
});
on(item_showVersion, "click", clickVersionInfo);
subMenuHelp.addChild(item_showVersion);
// [...]
this.addChild(new PopupMenuBarItem({
label : "Hilfe",
popup : subMenuHelp
}));
/* Meine Einstellungen */
var subMenuMySettings = new DropDownMenu({});
var item_showMySettings = new MenuItem({
label : "Meine Einstellungen"
});
subMenuMySettings.addChild(item_showMySettings);
// [...]
this.addChild(new PopupMenuBarItem({
label : "Meine Einstellungen",
popup : subMenuMySettings
}));
/* Administration */
// if (sessionHandler.getPermission == "admin") {
var subMenuAdmin = new DropDownMenu({});
var item_showUserManager = new MenuItem({
label : "Userverwaltung"
});
subMenuAdmin.addChild(item_showUserManager);
// [...]
this.addChild(new PopupMenuBarItem({
label : "Administration",
popup : subMenuAdmin
}));
// }
this.placeAt("navMenu");
this.startup();
} // [...]
})});
Unfortunately I get an error message "c is null". I guess there might be a problem with the this-function-call on the inherited addChild-method.
Anybody an idea?
Thanks in advance!