Have a look at the documentation of the button tap event. The first parameter in the callback function is the button that was tapped. It can be used for immediate manipulations. Have a look at this working example at fiddle.sencha.com
Set up your app.js with the controller and view in place.
Ext.application({
name : 'Fiddle',
controllers: [
'ButtonsController'
],
views: [
'ButtonsView'
],
launch : function() {
Ext.Viewport.add(Ext.create('Fiddle.view.ButtonsView'));
}
});
The controller references the buttons and sets a new text on the button that has been tapped.
Ext.define('Fiddle.controller.ButtonsController', {
extend: 'Ext.app.Controller',
config: {
refs: {
button: 'buttonsview button'
},
control: {
button: {
tap: 'onButtonTap'
}
}
},
onButtonTap: function(button) {
button.setText('Voted');
}
});
The view holds the buttons. The defaults config comes in handy, too.
Ext.define('Fiddle.view.ButtonsView', {
extend: 'Ext.Container',
xtype: 'buttonsview',
config: {
layout: 'vbox',
defaults: {
xtype: 'button',
cls: 'items'
},
items: [
{ text: 'Item1' },
{ text: 'Item2' },
{ text: 'Item3' },
{ text: 'Item4' }
]
}
});