PDA

View Full Version : Event Trigger Question



jhoweaa
6 Aug 2009, 12:57 PM
In an app that I'm working on, I have a form with several fields. We have event triggers set up to do certain actions when the value in the field changes. Some of our fields work in tandem. For example, we have a numberfield and a combo box. The combo box lets the user select currency (for example). What I would like to be able to do is cause the 'change' event to be fired on the numberfield when the user changes the combo box value. At the time the selection event occurs on the combo box, the combo knows its related field but I'm not sure how I can get that related field to fire its change event. Can anybody help me out?

Thanks!

steffenk
6 Aug 2009, 1:07 PM
why not fire it manually with fireEvent ?

jhoweaa
7 Aug 2009, 6:16 AM
why not fire it manually with fireEvent ?

I knew I was forgetting something. I'll give that a try.

Thanks!

jhoweaa
7 Aug 2009, 6:59 AM
why not fire it manually with fireEvent ?

I must be missing something. I can get the the input field element, but there is no fireEvent method (or onchange) so I must be doing something wrong or I'm misunderstanding how to get this thing to fire.

Condor
7 Aug 2009, 7:19 AM
How are you getting a reference to the number field?

Post some code.

jhoweaa
7 Aug 2009, 7:33 AM
How are you getting a reference to the number field?

Post some code.

Our form uses an hbox to surround a numberfield and combo box. I have a listener for the 'select' event on the combo box which is currently doing this:

function(combo, record, index) {
combo.ownerCt.items.items[0].getEl() ...
...
}

Not my favorite way to get things, but I'm just trying to get something to work. I know from the way we construct the hbox, that items[0] will contain the numberfield object. I do get an element from the getEl() call, I just don't know how to get it to fire a change event so that the change event defined on the numberfield will get called.

I see that there is a 'relayEvent' function on observables, but in this case I want to convert the 'select' event into a 'change' event and relay that on to the numberfield. I don't know of a way to make this happen.

Animal
7 Aug 2009, 7:44 AM
getEl()?

You are attempting to call fireEvent on that?

And as for getting the Field, haven't you read the docs on the ref config?

jhoweaa
7 Aug 2009, 9:39 AM
getEl()?

You are attempting to call fireEvent on that?

And as for getting the Field, haven't you read the docs on the ref config?

Actually I'm just trying to find the object that I *can* send fireEvent to. I had not read about the ref config (but I am now). Still with all the wrappers built up around Ext fields, which object *do* I need to talk to in order to get an event to fire? I thought that getEl would get me to the input field and I could talk to that, but that doesn't seem to be the case.

jhoweaa
7 Aug 2009, 9:58 AM
Ok, using the ref config I now see that I get an object which understands fireEvent. Thanks for the tip!