PDA

View Full Version : Stopping an Event from bubbling up.



j11extjs
30 Nov 2010, 11:30 PM
I have a button which does a submit. I get the ExtJS element for this button as follows:


var btnSubmit = Ext.get('btnSubmit');

Then I subscribe and declare a handler function as follows:


var onButtonSubmit = function(button, evtObj){
if(CheckValidProcessing()!=true) {
evtObj.stopEvent();
}
}


btnSubmit.on('click', onButtonSubmit);


The problem is the call to stopEvent(), says my evtObj does not have this method called stopEvent(). So I am not getting the proper event object in my handler as described in the 'click' event API for a button?


click (http://dev.sencha.com/deploy/dev/docs/source/Button.html#event-Ext.Button-click) : ( Button this, EventObject e )


Many thanks.

evant
30 Nov 2010, 11:34 PM
Because you're getting a reference to an element, not a button object. The first argument passed to an element is always the event.

j11extjs
1 Dec 2010, 1:56 AM
Thanks evant. I take it you mean the first argument passed to an event handler? And the solution is to use Ext.getCmp instead of Ext.get.