{ "id": "124194", "key": "TIMOB-16081", "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": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2014-02-20T22:28:07.000+0000", "created": "2013-12-26T16:16:58.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "supportTeam", "webview" ], "versions": [ { "id": "15479", "description": "Release 3.1.2", "name": "Release 3.1.2", "archived": true, "released": true, "releaseDate": "2013-07-31" }, { "id": "15593", "description": "Release 3.1.3", "name": "Release 3.1.3", "archived": true, "released": true, "releaseDate": "2013-09-18" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-22T22:32:30.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": "h3. Issue\r\n\r\nWhen using the beforeload and load events event to execute an action (show a loader) AJAX calls also fire the beforeload event but doesn't fire the load event.\r\n\r\nDocumentation mention that this event only if fire when loading local content, but on testing its being fired on remote content also.\r\n\r\nh3. Steps to Repro\r\n\r\n1. Run sample code on iOS device or simulator\r\n\r\nExpected Result:\r\n\r\nWhen the html is loaded the red overlay should hide.\r\n\r\nActual Result:\r\n\r\nThe html loads and hides the red overlay but when the ajax is called the red overlay is shown again and no load event is fired so the overlay doen't hide blocking the webview content.\r\n\r\n\r\nh3. Sample Code\r\n\r\n{code}\r\n\r\nvar window = Ti.UI.createWindow({\r\n\tbackgroundColor:\"white\"\r\n});\r\n\r\nvar webview = Ti.UI.createWebView({\r\n\turl:'http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations'\r\n});\r\n\r\nvar loader = Ti.UI.createView({\r\n\twidth:'80%',\r\n\theight:'60%',\r\n\tbackgroundColor:'red'\r\n});\r\n\r\nwebview.addEventListener('beforeload',function(e){\r\n\tTi.API.info(\"beforeload \"+e.url);\r\n\tloader.show();\r\n});\r\n\r\nwebview.addEventListener('load',function(e){\r\n\tTi.API.info(\"load \"+e.url);\r\n\tloader.hide();\r\n});\r\n\r\nwebview.addEventListener('error',function(e){\r\n\tTi.API.info(\"error \"+e.url);\r\n});\r\n\r\nwindow.add(webview);\r\nwindow.add(loader);\r\nwindow.open();\r\n\r\n{code}\r\n\r\nh3. Console Log\r\n\r\niOS Simulator \r\n\r\n{code}\r\n\r\n[DEBUG] : New scheme: { URL: http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations }\r\n[INFO] : beforeload http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations\r\n[DEBUG] : New scheme: { URL: http://www.hdsupply.com/locations/app.asp?lob=WC&source=WC&nobanner=1 }\r\n[INFO] : beforeload http://www.hdsupply.com/locations/app.asp?lob=WC&source=WC&nobanner=1\r\n[INFO] : load http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations\r\n[DEBUG] : New scheme: { URL: http://www.hdsupply.com/locations/app.asp?lat=37.3351212&lng=-122.03256229&rad=10&lob=WC&nobanner=1 }\r\n[INFO] : beforeload http://www.hdsupply.com/locations/app.asp?lat=37.3351212&lng=-122.03256229&rad=10&lob=WC&nobanner=1\r\n{code}\r\n\r\niOS Device\r\n\r\n{code}\r\n\r\nDec 26 09:27:30 iCotaman webviewandroid[454] : [DEBUG] New scheme: { URL: http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations }\r\nDec 26 09:27:30 iCotaman webviewandroid[454] : [INFO] beforeload http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations\r\nDec 26 09:27:30 iCotaman profiled[453] : (Note ) profiled: Service stopping.\r\nDec 26 09:27:35 iCotaman webviewandroid[454] : [DEBUG] New scheme: { URL: http://www.hdsupply.com/locations/app.asp?lob=WC&source=WC&nobanner=1 }\r\nDec 26 09:27:35 iCotaman webviewandroid[454] : [INFO] beforeload http://www.hdsupply.com/locations/app.asp?lob=WC&source=WC&nobanner=1\r\nDec 26 09:27:37 iCotaman webviewandroid[454] : [INFO] load http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations\r\nDec 26 09:27:42 iCotaman webviewandroid[454] : [DEBUG] New scheme: { URL: http://www.hdsupply.com/locations/app.asp?lat=19.35428288767054&lng=-99.12552894102328&rad=10&lob=WC&nobanner=1 }\r\nDec 26 09:27:42 iCotaman webviewandroid[454] : [INFO] beforeload http://www.hdsupply.com/locations/app.asp?lat=19.35428288767054&lng=-99.12552894102328&rad=10&lob=WC&nobanner=1\r\n\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: WebView firing 'beforeload' event by Ajax calls", "creator": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK: Mobile 3.1.X & 3.2\r\nPlatform OS Version: iOS6 & iOS7", "comment": { "comments": [ { "id": "294014", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "We need more details on this. Where is this ajax called? Where do I need to click?", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-20T21:48:42.000+0000", "updated": "2014-02-20T21:48:42.000+0000" }, { "id": "294018", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "You can also check what type of navigationType the beforeload event gives you and then show the view or do whatever needs to be done accordingly.\r\n\r\n{code}\r\nwebview.addEventListener('beforeload',function(e){\r\n Ti.API.info('navigationType: ' + e.navigationType);\r\n})\r\n{code}\r\n\r\n{code}\r\nTi.UI.WEBVIEW_NAVIGATIONTYPE_LINK_CLICKED\r\nTi.UI.WEBVIEW_NAVIGATIONTYPE_FORM_SUBMITTED\r\nTi.UI.WEBVIEW_NAVIGATIONTYPE_BACK_FORWARD\r\nTi.UI.WEBVIEW_NAVIGATIONTYPE_RELOAD\r\nTi.UI.WEBVIEW_NAVIGATIONTYPE_FORM_RESUBMITTED\r\nTi.UI.WEBVIEW_NAVIGATIONTYPE_OTHER\r\n{code}", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-20T21:57:34.000+0000", "updated": "2014-02-20T21:58:16.000+0000" }, { "id": "294021", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "This is a side effect of the fixes TIMOB-3370 and the limitations of the UIWebViewDelegate interface on iOS\r\n\r\nThe *beforeload* event is fired on webView:shouldStartLoadWithRequest:navigationType: delegate callback. \r\nThe *load* event is fired in the webViewDidFinishLoad: callback.\r\n\r\nWhile we have the URLRequest in the first delegate callback we have no such info in the second delegate callback. \r\n\r\nThe *beforeload* event fires with the url set to the url of the request in the callback.\r\nThe *load* event fires with the url set to WebView.request.url property.\r\n\r\nWe will not fire the *load* event if the WebView.request.url does not change (This is what TIMOB-3370 enforced).\r\nSo you might see a lot more *beforeload* events on iOS than load events.\r\n\r\niOS also returns the *navigationType* in the *beforeload* event. \r\nIf the navigationType is not *Titanium.UI.iOS.WEBVIEW_NAVIGATIONTYPE_OTHER* a *load* event is guaranteed. \r\n\r\nSo you might want to ignore all *beforeload* events where *navigationType* is *Titanium.UI.iOS.WEBVIEW_NAVIGATIONTYPE_OTHER*.\r\n", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-20T22:22:59.000+0000", "updated": "2014-02-20T22:26:09.000+0000" }, { "id": "294022", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Explanation of the load and beforeload events on iOS has been added. The problem the customer is facing can probably be solved by ignoring a few beforeload events. \r\n\r\nGoing to resolve this as needs more info.\r\n\r\nIf the problem is not solved by the workaround above, please re-open with exact steps for reproduction.", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-20T22:28:07.000+0000", "updated": "2014-02-20T22:28:07.000+0000" }, { "id": "294034", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Try this code as workaround\n{code}\nvar window = Ti.UI.createWindow({\n backgroundColor:\"white\"\n});\n \nvar webview = Ti.UI.createWebView({\n url:'http://mqa.qa-whitecap.ecom.hdsupply.com/webapp/wcs/stores/servlet/ContentDisplayView?catalogId=11101&langId=-1&storeId=11301&page=Store_Locations'\n});\n \nvar loader = Ti.UI.createActivityIndicator({\n message:'LOADING',\n backgroundColor:'black',\n color:'white',\n borderColor:'black',\n borderRadius:5,\n borderWidth:1\n});\n\n//Ensure first beforeload is processed. navigationType is other when setting url or data etc.\nvar firstLoad = true;\n \nwebview.addEventListener('beforeload',function(e){\n Ti.API.info(\"beforeload \"+e.url);\n if (firstLoad || e.navigationType != Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_OTHER) {\n firstLoad = false;\n Ti.API.info('*********LOAD******' + e.navigationType);\n loader.show();\n } else {\n Ti.API.info('*********NOLOAD******' + e.navigationType);\n }\n});\n \nwebview.addEventListener('load',function(e){\n Ti.API.info(\"load \"+e.url);\n loader.hide();\n});\n \nwebview.addEventListener('error',function(e){\n Ti.API.info(\"error \"+e.url);\n loader.hide();\n});\n \nwindow.add(webview);\nwindow.add(loader);\nwindow.open();\n{code}", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-20T23:08:14.000+0000", "updated": "2014-02-20T23:08:14.000+0000" }, { "id": "326036", "author": { "name": "ac", "key": "ac", "displayName": "Alvin Charles", "active": true, "timeZone": "America/Los_Angeles" }, "body": "@Vishal Duggal That worked fantastic for iOS. Is there any workaround for android also?", "updateAuthor": { "name": "ac", "key": "ac", "displayName": "Alvin Charles", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-29T05:36:24.000+0000", "updated": "2014-09-29T05:36:24.000+0000" }, { "id": "415138", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket due to the information that was requested not being provided.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-22T22:32:30.000+0000", "updated": "2017-03-22T22:32:30.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }