{ "id": "61168", "key": "TIMOB-536", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2011-04-15T02:31:21.000+0000", "created": "2011-04-15T02:31:20.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "1.0", "callback", "custom", "event" ], "versions": [], "issuelinks": [], "assignee": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-09T21:20:40.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
Using SDK1.0
\nThis Works:
\n\nTitanium.App.addEventListener('customEvent', function(e) {\n Ti.API.debug(\"FIRED!\");\n});\nTitanium.App.fireEvent('customEvent', {foo:'bar'});
\n
\nBut, this does not work. Event appears to fire (in console), but\ncallback is never executed:
\n\nvar tableView = Titanium.UI.createTableView();\nTitanium.UI.currentWindow.add(tableView);\n\nTitanium.App.addEventListener('customEvent', function(e) {\n Ti.API.debug(\"FIRED!\"); // never executed\n});\nTitanium.App.fireEvent('customEvent', {foo:tableView});
\n
\nThis also does not work, but perhaps is not expected to work.\nEvent is never fired:
\n\nvar tableView = Titanium.UI.createTableView();\nTitanium.UI.currentWindow.add(tableView);\n\ntableView.addEventListener('customEvent', function() {\n Ti.API.debug(\"FIRED!\"); // never executed\n});\ntableView.fireEvent('customEvent'); // never fires (according to console)
\n
The documentation does in fact state that the event data must be\nJSON serializeable. That is not true in the second case, which is\nconsistant with the documentation.
\nThe third example however is expected to work based on the\ndocumentation that says it does. See Ticket #581.
Maybe I'm missing something, but why should example 3 work?
\nSurely the line
\ntableView.fireEvent('customEvent');
\n
\nshould be
\nTi.App.fireEvent('customEvent');
\n
\nput inside a
\ntableView.addEventListener ?
\n
Noah
\nI take your point that the functionality is indeed in the docs, so\nmy suggestion could be used as an alternative if anyone is having\nissues with implementing example 3. However, I am still not clear\nabout the advantages of example 3. Is it just the tearing down\nthat's mentioned in #581 ?
For the reason why example 2 doesn't work, see this \nQ&A
\nTherefore, I think this ticket is just a duplication of #581. I\npropose that it be closed.
Dupe of #581.