Reputation: 21
I cant register any events with the "on" Mehotd.
Uncaught TypeError: Cannot call method 'on' of undefined
Ext.define('faragoo.view.Main', {
extend: 'Ext.Container',
alias: 'widget.stream',
xtype: 'stream',
id : 'stream',
requires: [
'Ext.TitleBar',
'Ext.form.Panel'
],
initialize: function () {
this.on('afterrender', function() { alert('rendered'); } );
}
}
And this simple example doesnt work also :
Ext.Viewport.on('orientationchange', function() { console.log("orientationchange"); }, this, {buffer: 50 });
Same Error :-(
Upvotes: 2
Views: 80
Reputation: 16847
This guide explains how to properly add events to a component.
Bind the event after the component is created:
var myButton = Ext.Viewport.add({
xtype: 'button',
text: 'Click me'
});
myButton.on('tap', function() {
alert("Event listener attached by .on");
});
Or bind an event with using a listener config:
Ext.Viewport.add({
xtype: 'button',
text: 'My Button',
listeners: {
tap: function() {
alert("You tapped me");
}
}
});
Upvotes: 1