Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#1814 closed defect (invalid)

DP: no way of differentiating DP1.onValueChanged from DP2.onValueChanged via eventHandler

Reported by: tk Owned by: tk
Priority: high Milestone:
Component: Widgets Version: 0.4
Keywords: Cc: bill, Adam Peller
Blocked By: Blocking:


If you have DP1 and DP2 and do dojo.event.connect(DP1,"onvaluechanged",'changeHandler'); dojo.event.connect(DP2,"onvaluechanged",'changeHandler');

all you get passed to changeHandler is "this.value" so you have no way of back tracking to see which DP called changeHandler.

Attachments (1)

DP_onValueChanged_fix.js (1.0 KB) - added by tk 16 years ago.
Possible fix for this problem

Download all attachments as: .zip

Change History (7)

Changed 16 years ago by tk

Attachment: DP_onValueChanged_fix.js added

Possible fix for this problem

comment:1 Changed 16 years ago by tk

Updating setDate and onValueChanged to this should solve this problem... at work so I cant test this at this time... Will test at home if nobody can before then.

comment:2 Changed 16 years ago by bill

Or you could just do this: dojo.event.connect(DP2,"onvaluechanged", function(value){changeHandler(value, DP2);} );

I'm not convinced that it's worth changing the signature of onValueChanged(), especially since that's a standard function across all form widgets.

comment:3 Changed 16 years ago by Adam Peller

I'm not sure there's always going to be an event to pass, so the proposed signature change might not work. Do we have conventions for arguments for on* functions? it would be nice if we had a standard way to get at the "target", even if it meant mocking up an object that looked like an event?

comment:4 Changed 16 years ago by bill

Right. Although most on*() methods handle DOM node events and thus take an Event argument, onValueChanged() is a higher-level callback that isn't tied to an event.

But besides that, it's hard to trace from an Event object to a widget that it applies to; if you want to know which widget the onValueChanged() was called on, an Event object is not a good way to do it.

comment:5 Changed 16 years ago by alex

Resolution: invalid
Status: newclosed

you can get at the source if you use around advice. It might be preferable if the onValueChanged() function passed it's "this" as a parameter, but I don't see that it's necessaray.

Marking invalid.

comment:6 Changed 15 years ago by (none)

Milestone: 0.4.1

Milestone 0.4.1 deleted

Note: See TracTickets for help on using tickets.