[ALOY-357] Button fires event "singletap" twice
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2012-11-02T16:34:04.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 0.3.1, 2012 Sprint 22 |
Components | n/a |
Labels | alloy, button |
Reporter | Ming Liu |
Assignee | Unknown |
Created | 2012-10-17T16:58:02.000+0000 |
Updated | 2018-03-07T22:25:45.000+0000 |
Description
Attachments
File | Date | Size |
---|---|---|
singletap.tgz | 2012-10-17T18:20:39.000+0000 | 54281 |
sample code
Seems like changing .on to .addEventListener solves the problem
This ended up being a pretty deep issue. The events firing twice were a symptom of a larger problem in the management of eventing done in order to wrap the Backbone eventing function for Titanium proxies. In short, the event listener only needs to be added to the proxy once, then its handling delegated to any number of handlers in the corresponding backbone listener(s). Listeners were being added to the proxy for _every_ new listener on a particular event added, which has been fixed. Same logic, except in reverse for the off() function as well. We only remove the event listener from the titanium proxy when there are no more listeners in the corresponding Backbone eventing.
@Ming: for reference, on() will work as expected when this change is pushed in 0.3.1. No need to use addEventListener() if you don't want. Thanks for taking the time to log this one cause it was actually a very important catch.
@Tony Thanks for getting this fixed. Looking forward to 0.3.1
@Tony: Thanks for this fix! :)