PDA

View Full Version : Triggerfield triggerclick event



slemmon
1 Mar 2012, 9:51 AM
Is there a trigger click event I can listen to in my controller for triggerfields? Or is overriding the field's protected onTriggerClick method the only way to respond to clicking on the trigger element?

tobiu
1 Mar 2012, 11:06 AM
the class has no own events yet, feel free to open a feature request.

you can also easily fire a custom event, like:



onTriggerClick: function() {
this.fireEvent('triggerclick', 'param1', 'param2');
}


and then listen to it in the controller.

slemmon
1 Mar 2012, 11:37 AM
ok. Can do.
While I have you here, since the fireEvent() works as you described what is the purpose/benefit of using addEvents('triggerclick') - or conversely a reason not to use addEvents()?

slemmon
1 Mar 2012, 2:19 PM
Triggerclick event now formally requested + and a story entered (for triggerclick and beforetriggerclick).

tobiu
1 Mar 2012, 4:21 PM
if you take a look at the sources:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.util.Observable-method-addEvents

you will see that the eventnames will get added to an event array. the firing works even without it, although it is much cleaner to add them there, since you directly know which extra events are there.

i also think that it is important for the other methods the observable has to offer like enableBubble, suspend events & resume.

slemmon
1 Mar 2012, 4:55 PM
Thx. I'd looked at the API docs, but not the source.
I always use addEvents when using fireEvent with a custom event personally, but only because I assumed it was best practice.

Thx again.