I’m trying to create my own LinkButton component in Ext JS 4. Nothing new, right?
My code looks like this:
Ext.define('LinkButton', {
extend: 'Ext.Component',
xtype: 'linkbutton',
autoEl: 'a',
renderTpl: '<a href=\"javascript:;\">{text}</a>',
config: {
text: '',
handler: function () { }
},
initComponent: function () {
var me = this;
me.callParent(arguments);
this.renderData = {
text: this.getText()
};
var handler = me.getHandler();
if (handler) {
me.on('click', handler);
}
}
});
So far so good! My LinkButton does look like a hyperlink anad my text content is in there. Graceful.
However, I can’t get my component to fire an event when I click on it!
This particular line me.on('click', handler); is not working! Even if I change it from on to addListener it has no effect.
So question is: How do I add DOM events to my component? Or, even better, how do I access my own component’s DOM element? I haven’t been able to do any of that!
Thanks!
Here is my proposition, which is basing on source from
Buttoncomponent:Working sample: http://jsfiddle.net/lolo/AEwH4/1/