{ "id": "127896", "key": "TIMOB-16648", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-03-20T16:45:18.000+0000", "created": "2014-03-20T12:41:45.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-14T21:08:03.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": "10230", "name": "BlackBerry", "description": "BlackBerry Platform" } ], "description": "h2. Description of the problem\r\nIn BB10, when a WebView is created with a remote URL, Ti does not seem to be defined. Thus, you cannot perform calls like Ti.App.fireEvent.\r\n\r\nh2. Steps to reproduce\r\nUse this code\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor:'white'\r\n});\r\n\r\nvar webview = Ti.UI.createWebView({\r\n\turl : 'http://www.example.com'\r\n});\r\n\r\nTi.App.addEventListener('geturl', function(e) {\r\n\talert('url: ' + e.url); // the url is defined\r\n});\r\n\r\nwebview.addEventListener('load', function() {\r\n\tsetTimeout(function() {\r\n\t\twebview.evalJS('Ti.App.fireEvent(\"geturl\", { \"url\": window.location.href })');\r\n\t}, 1000);\r\n});\r\n\r\nwin.add(webview);\r\nwin.open();\r\n{code}\r\n\r\nh2. Additional notes\r\nBy changing the 'url' property to a local file, Ti is defined, e.g.:\r\n\r\n{code}\r\nvar webview = Ti.UI.createWebView({\r\n\turl : 'test.html'\r\n});\r\n{code}\r\n\r\nAlso note that, even with local files Ti does not seem to be defined *unless* I add a timeout.", "attachment": [], "flagged": false, "summary": "BB: Ti is not defined when a WebView is created with a remote url", "creator": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "298047", "author": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "body": "One additional comment here. I noticed that this code works if I first load a local page, and then change the URL to a remote one:\n\n{code}\nvar win = Ti.UI.createWindow({\n backgroundColor:'white'\n});\n \nvar webview = Ti.UI.createWebView({\n url : 'test.html'\n});\nwebview.url = 'http://www.example.com';\n \nTi.App.addEventListener('geturl', function(e) {\n alert('url: ' + e.url); // the url is defined\n});\n \nwebview.addEventListener('load', function() {\n setTimeout(function() {\n webview.evalJS('Ti.App.fireEvent(\"geturl\", { \"url\": window.location.href })');\n }, 1000);\n});\n \nwin.add(webview);\nwin.open();\n{code}", "updateAuthor": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "created": "2014-03-20T12:43:11.000+0000", "updated": "2014-03-20T12:43:11.000+0000" }, { "id": "298083", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "The Ti namespace is not defined in a remote url WebView, this is expected behavior. I tested the same code in iOS and the event to get the url never fires. I placed an extra alert verify that the evalJS is getting called. Sample code with one more alert:\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor:'white'\r\n});\r\n \r\nvar webview = Ti.UI.createWebView({\r\n url : 'http://www.example.com'\r\n});\r\n \r\nTi.App.addEventListener('geturl', function(e) {\r\n alert('url: ' + e.url); // the url is defined\r\n});\r\n \r\nwebview.addEventListener('load', function() {\r\n setTimeout(function() {\r\n \talert('calling evalJS');\r\n webview.evalJS('Ti.App.fireEvent(\"geturl\", { \"url\": window.location.href })');\r\n }, 1000);\r\n});\r\n \r\nwin.add(webview);\r\nwin.open();\r\n{code}\r\n\r\nResolving as invalid.", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-03-20T16:45:18.000+0000", "updated": "2014-03-20T16:45:18.000+0000" }, { "id": "412317", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-14T21:08:03.000+0000", "updated": "2017-03-14T21:08:03.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }