PDA

View Full Version : CycleButton changeHandler not being fired



devilabit
23 Apr 2010, 8:57 AM
I have an issue using a CycleButton. When I create the CheckItems outside of the CycleButton the changeHandler function is not called:



var btn1 = new Ext.menu.CheckItem({
group:'grp',
text:'text only',
iconCls:'view-text',
checked:true
});

var btn2 = new Ext.menu.CheckItem({
group:'grp',
text:'HTML',
iconCls:'view-html'
});

var cycBtn = new Ext.CycleButton({
showText: true,
prependText: 'View as ',
items: [btn1, btn2],
changeHandler:function(btn, item){
Ext.Msg.alert('Change View ', item.text);
}
});
However when i create the CheckItem's inside the CycleButton changeHandler is called as expected:



var cycBtn2 = new Ext.CycleButton({
showText: true,
prependText: 'View as ',
items: [{
text:'text only',
iconCls:'view-text',
checked:true
},{
text:'HTML',
iconCls:'view-html'
}],
changeHandler:function(btn, item){
Ext.Msg.alert('Change View', item.text);
}
});
Is this a bug or am I doing something stupid?

Thanks.

devilabit
23 Apr 2010, 12:46 PM
I should have read the docs again, it clearly says that a CycleButton contains a menu with:

An array of Ext.menu.CheckItem (http://www.extjs.com/deploy/dev/docs/output/Ext.menu.CheckItem.html) config objects to be used when creating the button's menu items