PDA

View Full Version : Which Object?



GregT
30 Sep 2009, 4:45 AM
Suppose I have a half-dozen Buttons all pointing to the same Click event handler called 'generic-click-handler'. Inside that event handler, I need to be able to tell which of the five buttons was clicked. How is this best done?

I get that I probably need 'getTarget' but I have been fiddling around with the various id, idTag, srcElement etc. properties and none of them seem to do what I want...

BTW, I assume that this is a reasonable thing to do, when all five buttons to the same general task with slightly different parameters.

jay@moduscreate.com
30 Sep 2009, 5:06 AM
The button is the first parameter passed by the click handler. There is no reason why you cant figure it out with that reference alone.

GregT
30 Sep 2009, 7:40 AM
Thank you, I was aware of that, but I am having trouble finding a property that works and tells me which button was clicked. I am looking for something like the 'Name' or 'Tag' property that you get in C#.

Your product is totally amazing, by the way. I have to delve into the source a bit and figure out how it does what it does so well.

jay@moduscreate.com
30 Sep 2009, 8:06 AM
It's not my product :).

Are you familiar with Firebug?

GregT
30 Sep 2009, 9:11 AM
Well it seems to be youir product in the sense that you are very helpful about it.

I use FB, but I am familiar with it in the way that you and I are familiar with the controls of 1 747. I think the little levers in the middle make it go faster, and I think the little steering wheel thing makes it turn. Not sure what the 1,000 other switches and dials do.

Mostly I just look at the FB Console and occasionally the DOM. I have been meaning to invest some time in understanding it properly...

jay@moduscreate.com
30 Sep 2009, 9:21 AM
Right click on the tab and click 'inspect element', then activate/deactivate it. you'll see the changes to the DOM in front of your eyes.

Animal
30 Sep 2009, 10:54 AM
You can't hurt yourself learning to use Firebug!

So click, drag, right click everything there and see what happens.

There's no manual, that's how we all learned.

GregT
1 Oct 2009, 8:16 AM
OK, so it looks like the 'id' property can be set at Button create time and used to identify the button. I'm not sure why I couldn't find that before ;) Thanks as always.

jay@moduscreate.com
1 Oct 2009, 8:34 AM
yes, you can use ID. just be aware that it has implications, such as only one component can be registered in component manager with that ID