{ "id": "112007", "key": "ALOY-596", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2014-05-01T20:25:17.000+0000", "created": "2013-03-31T20:03:14.000+0000", "priority": null, "labels": [ "alloy" ], "versions": [], "issuelinks": [], "assignee": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "updated": "2014-05-01T20:25:17.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "app/controllers/home.js:\r\n//////////////////////////////////////////\r\nvar openBrowserOverlay;\r\n\r\nopenBrowserOverlay = function() {\r\n alert(\"Clicked!\");\r\n};\r\n//////////////////////////////////////////\r\n\r\napp/views/home.xml:\r\n//////////////////////////////////////////\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n//////////////////////////////////////////\r\n\r\nWhen clicking \"addButton\" the function is called 2 times (alert appears 2 times)\r\n\r\nHowever, changing app/controllers/home.js to:\r\n//////////////////////////////////////////\r\nfunction openBrowserOverlay() {\r\n alert(\"Clicked!\");\r\n};\r\n//////////////////////////////////////////\r\nSolves the problem.\r\n\r\nIt'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\".\r\n", "attachment": [], "flagged": false, "summary": "Function is being called twice When adding alternate Window platform=\"android\" on view.xml", "creator": { "name": "mardo", "key": "mardo", "displayName": "Mardo Del Cid", "active": true, "timeZone": "America/Guatemala" }, "subtasks": [], "reporter": { "name": "mardo", "key": "mardo", "displayName": "Mardo Del Cid", "active": true, "timeZone": "America/Guatemala" }, "environment": "Titanium 3.0.2\r\nMacOS 10.7.5", "comment": { "comments": [ { "id": "245178", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "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.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-02T14:21:45.000+0000", "updated": "2013-04-02T14:21:45.000+0000" }, { "id": "245196", "author": { "name": "mardo", "key": "mardo", "displayName": "Mardo Del Cid", "active": true, "timeZone": "America/Guatemala" }, "body": "Hello Tony,\n\nI'm testing on the iOS Simulator, not on Android.\nAlso, i would like to remark that works OK when using the standard way to define a function:\n{code:JavaScript}\nfunction openBrowserOverlay() { \n alert(\"Clicked!\"); \n};\n{code}\n\nBut it's called twice when defining the function as a variable:\n{code:JavaScript}\nvar openBrowserOverlay;\nopenBrowserOverlay = function() { \n alert(\"Clicked!\"); \n};\n{code}\n\n\nTo easily replicate the issue, create a new alloy app and change\n\n*index.js* to:\n{code:JavaScript}\nvar doClick = function(e) { \n alert($.label.text);\n}\n\n$.index.open();\n{code}\n\n*index.xml* to:\n{code:xml}\n\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\n{code}\n// Note that i added *platform=\"ios\"* to the first Window\n\nAnd run it with iOS Simulator:\ntitanium build -p ios\n\nP.S. Thanks for the great framework!", "updateAuthor": { "name": "mardo", "key": "mardo", "displayName": "Mardo Del Cid", "active": true, "timeZone": "America/Guatemala" }, "created": "2013-04-02T16:06:05.000+0000", "updated": "2013-04-02T16:06:05.000+0000" }, { "id": "294812", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "This appears to be resolved by the fix for ALOY-691. ", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-02-26T17:28:08.000+0000", "updated": "2014-02-26T17:28:08.000+0000" }, { "id": "303222", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "Tested and confirmed that this is no longer an issue thanks to the changes made in ALOY-691.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-05-01T20:25:17.000+0000", "updated": "2014-05-01T20:25:17.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }