{ "id": "110086", "key": "ALOY-545", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "15271", "description": "Alloy 1.1.0, concurrent with SDK 3.1.0", "name": "Alloy 1.1.0", "archived": false, "released": true, "releaseDate": "2013-04-16" }, { "id": "14875", "description": "2013 Sprint 06", "name": "2013 Sprint 06", "archived": true, "released": true, "releaseDate": "2013-03-25" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-03-18T20:50:20.000+0000", "created": "2013-02-23T22:20:46.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "alloy", "compiler", "controller", "views", "xml" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-03-07T22:25:57.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": [ { "id": "12326", "name": "XML", "description": "View XML and parsing" } ], "description": "If you require a widget in a XML view like this:\r\n\r\n{code}\r\n\r\n{code}\r\n\r\nIt generates code like this:\r\n\r\n{code}\r\n$.__views.myWidget = Alloy.createWidget(\"nl.fokkezb.tweetsView\", \"widget\", {\r\n id: \"myWidget\",\r\n foo: \"bar\"\r\n});\r\n{code}\r\n\r\nLet’s take a look at the code for createWidget in alloy.js:\r\n\r\n{code}\r\nexports.createWidget = function(id, name, args) {\r\n return new (require(\"alloy/widgets/\" + id + \"/controllers/\" + (name || \"widget\")))(args);\r\n};\r\n{code}\r\n\r\nAs you can see, the second argument specifies the controller to require from the widget. You might not have known this, but the docs do mention that widget can contain multiple view-controllers, just like your app does.\r\n\r\nUnfortunately, to use this feature you need to create the widget in your controller using code similar to the second fragment above. It’s currently not possible to do this in the view.\r\n\r\nThis is a missed opportunity to use a singe widget to expose a collection of reusable UI elements:\r\n\r\n{code}\r\n\r\n \r\n \r\n \r\n …\r\n\r\n{code}\r\n\r\nOr create a widget that can be used in multiple contexts:\r\n\r\n{code}\r\n\r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\nSo my feature request / improvement would be to support the name attribute for elements, whose value would be used as the second argument for createWidget. I’ve made the necessary changes to Alloy.Require.js and did a pull request for this:\r\n\r\nhttps://github.com/appcelerator/alloy/pull/111", "attachment": [], "flagged": false, "summary": "Setting widget view-controller from within XML views", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "Any", "comment": { "comments": [ { "id": "242751", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Also updated widgets/basic test app to use this functionality: \r\n\r\nhttps://github.com/appcelerator/alloy/tree/master/test/apps/widgets/basic", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-03-18T20:50:20.000+0000", "updated": "2013-03-18T20:50:20.000+0000" }, { "id": "251769", "author": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested the app - https://github.com/appcelerator/alloy/tree/master/test/apps/widgets/basic\r\nIt is working fine with alloy version 1.1.2.Can close the bug.", "updateAuthor": { "name": "sbhadauria", "key": "sbhadauria", "displayName": "Shyam Bhadauria", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-14T10:33:43.000+0000", "updated": "2013-05-14T10:33:43.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }