PDA

View Full Version : Help: Ext.Element on method



java9394
26 Sep 2007, 12:03 PM
From the example on the Manual:Intro:Event Handling page:

var el = Ext.get('somelink');
el.on('click', function(){
alert('you click on a link');
});

I wonder where this "on" method inherited from. I checked the API doc, but I didn't see the "on" there :-?

thnx.

MaximGB
26 Sep 2007, 12:05 PM
It's a shortcut to Element::addListener method
Element.js line 2681

ep.on = ep.addListener;

devnull
26 Sep 2007, 1:51 PM
actually I believe it comes from Ext.util.Observable;
http://extjs.com/deploy/ext/docs/output/Ext.util.Observable.html#on

evant
26 Sep 2007, 2:43 PM
Not quite, because Ext.Element doesn't inherit from Observable, see:



addListener : function(eventName, fn, scope, options){
Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
},


Makes a call directly to the event manager.

MaximGB
26 Sep 2007, 2:45 PM
actually I believe it comes from Ext.util.Observable;
http://extjs.com/deploy/ext/docs/out...rvable.html#on
You are wrong Ext.Element isn't a child of Ext.util.Observable.

devnull
26 Sep 2007, 3:33 PM
Well thats one thing that is very hard to do in the docs; trace inheritance. I tried.