Opened 15 years ago

Closed 14 years ago

#2507 closed defect (wontfix)

Can't use dojo.event.connect on RadioGroup's onItemSelect event

Reported by: guest Owned by: Tom Trenka
Priority: high Milestone:
Component: Dojox Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:


The test page for RadioGroup? includes the following code:

dojo.event.connect(dojo.widget.byId("group1"), "onItemSelect", function(e) {

dojo.dom.removeChildren(dojo.byId("debugContainer")); dojo.debug("RadioGroup? item with value <" + dojo.dom.textContent(dojo.widget.byId("group1").selectedItem) + "> selected");


But the function doesn't get fired when items in the radio group are selected. After some rooting around, I found that the onItemSelect is connected to onclick by the following line in RadioGroup?.js: dojo.event.browser.addListener(node, "onclick", dojo.lang.hitch(this, "onItemSelect"));

The problem is that dojo.lang.hitch dereferences "onItemSelect" to a function pointer and returns a function that calls that function pointer. If you later call dojo.event.connect with "onItemSelect" the onItemSelect function on the radio group object is replaced with a new joinpoint function which in turn calls the original onItemSelect. At this point, though, the onclick now calls the *original* onItemSelect, *not* the new joinpoint implementation of onItemSelect. The connect, therefore, never gets called when you click the control.

There seem to be two ways to fix this to me. I modified the RadioGroup? code to use dojo.event.connect to connect onclick to onItemSelect. (I also similarly modified the line that adds a listener for onSelect.) This seems to work fine.

The other way to do this would be to not dereference the function name in dojo.lang.hitch at the call time of hitch but rather at the call time of the returned function. This would make hitch more dynamic than it currently is (sort of like the concept of "late binding" in COM/VB), and I'm sure it would have a lot of unintended effects. I don't know enough about the design and spec of hitch to know if this is a good idea or not.

Change History (4)

comment:1 Changed 15 years ago by guest

Sorry, I'm the submitter, and my contact info is xander76 at the site that is a competitor to google and rhymes with mahoo.

comment:2 Changed 15 years ago by bill

Component: WidgetsDojox
Owner: changed from bill to jkuhnert

comment:3 Changed 15 years ago by Tom Trenka

Owner: changed from jkuhnert to Tom Trenka

comment:4 Changed 14 years ago by Tom Trenka

Resolution: wontfix
Status: newclosed

This widget did not get ported from 0.4 to 1.0, so I'm going to close this ticket. Keep in mind that a form of it may show back up in DojoX or somewhere else at some point, and when it does we'll ensure this is no longer an issue.

Note: See TracTickets for help on using tickets.