#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: |
Description
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)
Change History (7)
Changed 14 years ago by
Attachment: | DP_onValueChanged_fix.js added |
---|
comment:1 Changed 14 years ago by
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 14 years ago by
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 14 years ago by
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 14 years ago by
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 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
Possible fix for this problem