[ALOY-596] Function is being called twice When adding alternate Window platform="android" on view.xml
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Duplicate |
Resolution Date | 2014-05-01T20:25:17.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | alloy |
Reporter | Mardo Del Cid |
Assignee | Tim Poulsen |
Created | 2013-03-31T20:03:14.000+0000 |
Updated | 2014-05-01T20:25:17.000+0000 |
Description
app/controllers/home.js:
//////////////////////////////////////////
var openBrowserOverlay;
openBrowserOverlay = function() {
alert("Clicked!");
};
//////////////////////////////////////////
app/views/home.xml:
//////////////////////////////////////////
//////////////////////////////////////////
When clicking "addButton" the function is called 2 times (alert appears 2 times)
However, changing app/controllers/home.js to:
//////////////////////////////////////////
function openBrowserOverlay() {
alert("Clicked!");
};
//////////////////////////////////////////
Solves the problem.
It's only happening when defining the function with "var" (BTW, it's the way coffeescript defines functions, that's why i noticed) and having an alternate Window with platform="android".
It looks like on android you'll have 2 windows/buttons right on top of each other, and the buttons will both have the id "addButton". This would likely account for the alert being called twice. I'm going to close this for now and will re-open if more details are provided.
Hello Tony, I'm testing on the iOS Simulator, not on Android. Also, i would like to remark that works OK when using the standard way to define a function:
But it's called twice when defining the function as a variable:
To easily replicate the issue, create a new alloy app and change *index.js* to:
*index.xml* to:
// Note that i added *platform="ios"* to the first Window And run it with iOS Simulator: titanium build -p ios P.S. Thanks for the great framework!
This appears to be resolved by the fix for ALOY-691.
Tested and confirmed that this is no longer an issue thanks to the changes made in ALOY-691.