PDA

View Full Version : [UNKNOWN][3.x] Menu's autoLayout option



Animal
14 Dec 2009, 8:26 AM
The MenuLayout by default automatically calls doLayout on add and remove to ensure that the UI is kept up to date. That's good (Except for during construction).

But the event passes parameters which are then passed into doLayout and used as the "shallow" and "forceLayout" arguments..

The code should be



initComponent : function(){
if(Ext.isArray(this.initialConfig)){
Ext.apply(this, {items:this.initialConfig});
}
this.addEvents(
/**
* @event click
* Fires when this menu is clicked (or when the enter key is pressed while it is active)
* @param {Ext.menu.Menu} this
* @param {Ext.menu.Item} menuItem The menu item that was clicked
* @param {Ext.EventObject} e
*/
'click',
/**
* @event mouseover
* Fires when the mouse is hovering over this menu
* @param {Ext.menu.Menu} this
* @param {Ext.EventObject} e
* @param {Ext.menu.Item} menuItem The menu item that was clicked
*/
'mouseover',
/**
* @event mouseout
* Fires when the mouse exits this menu
* @param {Ext.menu.Menu} this
* @param {Ext.EventObject} e
* @param {Ext.menu.Item} menuItem The menu item that was clicked
*/
'mouseout',
/**
* @event itemclick
* Fires when a menu item contained in this menu is clicked
* @param {Ext.menu.BaseItem} baseItem The BaseItem that was clicked
* @param {Ext.EventObject} e
*/
'itemclick'
);
Ext.menu.MenuMgr.register(this);
if(this.floating){
Ext.EventManager.onWindowResize(this.hide, this);
}else{
if(this.initialConfig.hidden !== false){
this.hidden = false;
}
this.internalDefaults = {hideOnClick: false};
}
Ext.menu.Menu.superclass.initComponent.call(this);
if(this.autoLayout){
var fn = this.doLayout.createDelegate(this, []);
this.on({
add: fn,
remove: fn
});
}
},