PDA

View Full Version : Dynamically adding items to a toolbar (should be an easy question)



d5chris
20 Feb 2011, 2:17 PM
Hi all, i have a toolbar which is set up like so:

MyApp.Guide.channelbar = new Ext.Toolbar({
items: [
{
text: 'loading...',
ui: 'plain',
disabled: true
}
]
});

It displays on the screen as expected, and looks just fine. So later on, i make a JSONP request and in the callback, i try to remove the loading item and insert a segmented button like so:

MyApp.Guide.channelbar.items.add(
new Ext.SegmentedButton({
name: 'testseg',
items: [{text:'test a'},{text:'test b'}]
}));

Now i'm *certain* that callback is getting called, because in chrome's console i do the following to confirm that the item has been added:

MyApp.Guide.channelbar.items.items[1].name

But it just doesn't get updated on the screen. What am i missing?

mitchellsimoens
20 Feb 2011, 3:58 PM
Don't add the button to the item object.


MyApp.Guide.channelbar.add({ ... })

d5chris
20 Feb 2011, 4:18 PM
Thanks.
Also found i needed to call doLayout() on the toolbar too.