Opened 8 years ago

Closed 7 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)

icon-connect.html (1.1 KB) - added by Ming Zhe Huang 8 years ago.
test case

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by Ming Zhe Huang

Attachment: icon-connect.html added

test case

comment:1 Changed 8 years ago by ykami

Cc: Atsushi Ono added

comment:2 Changed 8 years ago by Atsushi Ono

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 in reply to:  2 Changed 8 years ago by Ming Zhe Huang

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 8 years ago by ykami

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 8 years ago by bill

Milestone: tbd

comment:6 Changed 7 years ago by Atsushi Ono

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 7 years ago by ykami

Milestone: tbd1.8
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.