Opened 9 years ago
Closed 9 years ago
#14241 closed defect (fixed)
[IconItem] Connect "iconClicked" and it will be triggered twice
Reported by: | Ming Zhe Huang | Owned by: | ykami |
---|---|---|---|
Priority: | high | Milestone: | 1.8 |
Component: | DojoX Mobile | Version: | 1.7.0 |
Keywords: | Cc: | Atsushi Ono | |
Blocked By: | Blocking: |
Description
Please try the attached test case.
If we use dojo/_base/connect to connect to "iconClicked", the alert dialog will be popped up twice. This cause some trouble for custom event handling, because there's no "onclick" of ListItem? and we rely on "iconClicked" to monitor clicking event.
Attachments (1)
Change History (8)
Changed 9 years ago by
Attachment: | icon-connect.html added |
---|
comment:1 Changed 9 years ago by
Cc: | Atsushi Ono added |
---|
comment:2 follow-up: 3 Changed 9 years ago by
IconItem#iconClicked is called twice during a click event for a reason now. In your case, how about connecting to the iconNode's "onclick" event handler as below?
dojo.connect(iconItemWidget.iconNode, "onclick", function(e) { ... });
comment:3 Changed 9 years ago by
Replying to onoat:
IconItem#iconClicked is called twice during a click event for a reason now. In your case, how about connecting to the iconNode's "onclick" event handler as below?
dojo.connect(iconItemWidget.iconNode, "onclick", function(e) { ... });
This is exactly what I'm doing now :) There's a recursion in iconClicked(). Can we split that part into a new function to avoid duplicated call?
comment:4 Changed 9 years ago by
Archer, the recursion is necessary to ensure that the pressed icon color changes before the click action runs. We will change the name of the event handlers, for example from onClick to _onClick, just like dijit, in 1.8.
comment:5 Changed 9 years ago by
Milestone: | → tbd |
---|
comment:6 Changed 9 years ago by
This issue cannot be reproduced any more in the latest code because of the recent changes around onClick event handlers in #14428 (although actual changes for IconItem were committed in #14662).
Now IconItem#iconClicked is renamed to IconItem#_onClick, and you can use IconItem#onClick event handler which should be invoked just once on each click event.
comment:7 Changed 9 years ago by
Milestone: | tbd → 1.8 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
test case