{ "id": "154559", "key": "TIMOB-20286", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-01-05T01:26:47.000+0000", "created": "2016-01-28T17:48:57.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "ios", "windows" ], "versions": [], "issuelinks": [ { "id": "53814", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "164981", "key": "TIMOB-24213", "fields": { "summary": "Support generic view-selector e.g. querySelectorAll", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-06-04T08:36:12.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": "10202", "name": "Android", "description": "Android Platform" }, { "id": "10206", "name": "iOS", "description": "iOS Platform" }, { "id": "12642", "name": "Windows", "description": "Windows authoring support" } ], "description": "To facilitate a common web pattern (such as JQuery $ or DOM selector getElementById), we should support a simple selector like syntax or at a minimum getElementById-like API.\r\n\r\nMy suggestion would be something like Ti.UI.getViewById which would return the view object or null if not found.\r\n", "attachment": [], "flagged": false, "summary": "Support getElementById method to lookup views by ID", "creator": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 787, "state": "closed", "name": "2017 Sprint 01 SDK", "startDate": "2016-12-31T02:15:33.446Z", "endDate": "2017-01-14T02:15:00.000Z", "completeDate": "2017-01-15T00:00:19.006Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "375447", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "http://stackoverflow.com/questions/35068169/select-dynamically-generated-element-by-id-in-titanium-appcelerator/35068348#35068348", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-01-28T18:46:14.000+0000", "updated": "2016-01-28T18:46:14.000+0000" }, { "id": "403135", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~cng] This is currently scheduled for 6.1.0. Thinking about the implementation, we could use the proposed {{Ti.UI.View.getViewById}} method and inherit it to the subclasses of it. We would set the {{id}} property of the proxy and loop through the view's children to determine the correct view. I don't see many problems there, and parity would be doable as well. /cc [~gmathews]\r\n\r\niOS/Android PR: https://github.com/appcelerator/titanium_mobile/pull/8677\r\n\r\nTest-Case:\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n\r\nvar container = Ti.UI.createView({\r\n width: 300,\r\n height: 300,\r\n backgroundColor: 'red'\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n title: 'Get view by ID',\r\n id: 'myButton'\r\n});\r\n \r\nbtn.addEventListener('click', function() {\r\n var myButton = win.getViewById('myButton');\r\n \r\n // If no button is found, it will return null\r\n if (myButton) {\r\n myButton.setTitle('Worked!');\r\n }\r\n});\r\n \r\ncontainer.add(btn);\r\nwin.add(container);\r\nwin.open();\r\n{code}\r\n\r\nThis change is perfect for unit-tests as well. Will do those this week.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-12-11T13:01:37.000+0000", "updated": "2016-12-11T20:48:23.000+0000" }, { "id": "403160", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "jQuery's {{$()}} is effectively {{document.querySelectorAll()}}, which is actually pretty involved. Simply being able to find a UI element by ID is going to be MUCH easier and it's a good start.\r\n\r\nIf we plan to support something like {{document.querySelectorAll()}}, which I support, then it really needs to work with CSS selector syntax. However, it makes the most sense to support this in the context of Alloy where there are \"tags\".\r\n\r\nIf this ticket is to only support getting an element by ID, then we should update this ticket's title.\r\n\r\n[~hansknoechel] Note that {{getElementById()}} will return an array of elements if there are more than one that matches the specified ID. Not saying we need to do the same, but it's a great idea.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2016-12-12T10:24:22.000+0000", "updated": "2016-12-12T10:24:22.000+0000" }, { "id": "403163", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~eharris] Yes, definitely!\r\n[~cbarber] Thanks for the feedback! I guess we can expose all selectors then. And I'll change the existing implementation to return an array for multiple results. ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-12-12T11:40:45.000+0000", "updated": "2016-12-12T11:40:45.000+0000" }, { "id": "403166", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~hansknoechel] \"Expose all selectors\"? Not sure I follow.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2016-12-12T12:21:13.000+0000", "updated": "2016-12-12T12:21:13.000+0000" }, { "id": "403171", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I meant the {{querySelectorAll}} method. So we would support something like {{view.querySelectorAll('#myButton, .myLabel')}}? In Alloy, I think that classes are assigned using the {{className}} property, so we could search that one as well. Then we would need an algorithm to process the arguments and implement it on each platform. If so, we should move the whole thing to 6.2.0 and think about a proper architecture first.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-12-12T15:26:21.000+0000", "updated": "2016-12-12T15:26:21.000+0000" }, { "id": "403173", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "That's what I'm getting at. Adding a \"get by id\" is easy and we should do today, but supporting selectors is not easy and probably only makes sense in the context of Alloy. So, probably best to rename this ticket to \"get element by id\" and create a new ticket to support selectors.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2016-12-12T15:34:22.000+0000", "updated": "2016-12-12T15:34:22.000+0000" }, { "id": "403174", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Agree, thx Chris! Created TIMOB-24213 as a follow-up.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-12-12T15:54:17.000+0000", "updated": "2016-12-12T15:57:56.000+0000" }, { "id": "403706", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "PR for Windows: https://github.com/appcelerator/titanium_mobile_windows/pull/911", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-12-21T02:32:47.000+0000", "updated": "2016-12-21T02:32:47.000+0000" }, { "id": "404609", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified improvement with the test case provided above, no error is shown when {{getElementById}} is used. \r\n\r\n*iOS and Android environment* \r\n{code:java}\r\nAppcelerator Command-Line Interface, version 6.1.0\r\nAndroid 7.1 (Google Nexus 6P)\r\niOS 10.1.1 (iPhone 7)\r\nOperating System Name: Mac OS X El Capitan\r\nOperating System Version: 10.11.6\r\nNode.js Version: 4.6.0\r\nnpm: 4.2.8\r\nTitanium SDK Version: 6.1.0.v20170112013001\r\nXcode: 8.2\r\nAppcelerator Studio: 4.8.1.201612050850\r\n{code}\r\n\r\n*Windows Environment*\r\n{code:java}\r\nNokia Lumia 640 LTE (RM-1073)\r\nVersion 1607 (OS build: 10.14393.576)\r\nOperating System\r\nName = Microsoft Windows 10 Pro\r\nVersion = 10.0.14393\r\nArchitecture = 64bit\r\n# CPUs = 4\r\nMemory = 17034395648\r\n \r\nNode.js\r\nNode.js Version = 4.4.4\r\nnpm Version = 2.11.3\r\n \r\nTitanium SDK\r\nSDK Version = 6.1.0.v20170112013001\r\n{code}\r\n\r\n\r\n", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-01-13T21:45:01.000+0000", "updated": "2017-01-13T21:45:01.000+0000" }, { "id": "438083", "author": { "name": "Andrea.Vitale", "key": "andrea.vitale", "displayName": "Andrea Vitale", "active": true, "timeZone": "Europe/Berlin" }, "body": "I'm using the latest 7.2.0 build and getViewById works well on iOS, not on Android.\r\n\r\n\r\n{code}\r\n\r\n\t\r\n\t\t\r\n\t\t\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nIf I try to get the {{ActivityIndicator}} reference using {{const loader = event.row.getViewById('Loader');}} inside the TableView click event, on iOS it correctly gives me the ActivityIndicator instance, on Android gives a null value.\r\n", "updateAuthor": { "name": "Andrea.Vitale", "key": "andrea.vitale", "displayName": "Andrea Vitale", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-04T08:36:12.000+0000", "updated": "2018-06-04T08:36:12.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }