How can I bind event for all buttons in my ExtJS app? like JQuery:
$('button').click(function(el) {
console.log($(el).getattr('value'));
});
Two ways:
If you're writing a full app following Ext's MVC pattern, you have to instantiate an Ext.Application
and use a controller with code like the following
Sample Code
Ext.define('MyApp.controller.Buttons', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'button': {
click: function() { ... }
}
});
}
});
The hacked up way is to do a query and bind a separate handler for each button
Ext.Array.each(Ext.ComponentQuery.query('button'), function(btn)) {
btn.on('click', function() {...});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With