[ALOY-596] Function is being called twice When adding alternate Window platform="android" on view.xml

GitHub Issuen/a
Resolution Date2014-05-01T20:25:17.000+0000
Affected Version/sn/a
Fix Version/sn/a
ReporterMardo Del Cid
AssigneeTim Poulsen


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".


  1. Tony Lukasavage 2013-04-02 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.
  2. Mardo Del Cid 2013-04-02 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:
       function openBrowserOverlay() { 
    But it's called twice when defining the function as a variable:
       var openBrowserOverlay;
       openBrowserOverlay = function() { 
    To easily replicate the issue, create a new alloy app and change *index.js* to:
       var doClick = function(e) {  
    *index.xml* to:
       	<Window class="container" platform="ios">
       		<Label id="label" onClick="doClick">Hello, World</Label>
       	<Window id="self" platform="android">
       		<Label id="label" onClick="doClick">Hello, World</Label>
    // 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!
  3. Tim Poulsen 2014-02-26 This appears to be resolved by the fix for ALOY-691.
  4. Tim Poulsen 2014-05-01 Tested and confirmed that this is no longer an issue thanks to the changes made in ALOY-691.

JSON Source