{ "id": "113274", "key": "ALOY-639", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2013-04-23T09:13:00.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "alloy", "data-binding" ], "versions": [], "issuelinks": [], "assignee": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "updated": "2015-11-27T02:57:10.000+0000", "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" } }, "components": [ { "id": "13605", "name": "Models" }, { "id": "12329", "name": "Runtime", "description": "Generic bucket for uncategorized runtime issues" } ], "description": "This issue was part of ALOY-504 but now separated.\r\n\r\nNow we have the {{dataFunction}} attribute in place, we can manually trigger updating a data-bound view. This issue takes it a step further and asks for the generated data-function to be able to work with general objects/arrays.\r\n\r\nindex.xml\r\n{code:xml}\r\n\r\n \r\n\r\n{code}\r\n\r\nindex.js\r\n{code:JavaScript}\r\nfunction filterData(data) {\r\n return _.where(data, { title: 'Two' }); \r\n}\r\n\r\nfunction transformItem(item) {\r\n var transform = _.clone(item);\r\n transform.title = title + ' ' + _.random(1, 10);\r\n return transform;\r\n}\r\n\r\nfillTable([\r\n { title: 'One' },\r\n { title: 'Two' },\r\n { title: 'Three' }\r\n]);\r\n{code}\r\n\r\ngenerated data-funtion\r\n{code:JavaScript}\r\nfunction fillTable(data) {\r\n // Apply filter on passed data instead of a collection\r\n var models = dataFilter(data);\r\n\r\n // remove existing stuff like normal\r\n\r\n // Use Underscore's each instead of a for-loop\r\n _.each(data, function (_alloyId*N*) {\r\n // Apply transform on item like normal\r\n _alloyId*N*.__transform = dataTransform(_alloyId*N*);\r\n // Generate and add views like normal\r\n }\r\n}\r\n{code}\r\n\r\nSome notes:\r\n\r\n* The {{dataTransform}} and {{dataFilter}} implementations won't need to be changed since the user is responsible for what happens inside these functions and the input and output when called on regular objects would be exactly the same.\r\n* The generated data-function would need to accept an object/array as argument.\r\n* The generated data-function would need to use {{_.each}} instead of a for-loop, because it needs to support any loop-able data.\r\n* In case a {{dataCollection}} attribute was specified, the first line in the generated data-funtion could be changed to {{var models = dataFilter(data || _alloyId*N*);}} so the data-function would both work on the bound collection as well as manually called with custom data.\r\n", "attachment": [], "flagged": false, "summary": "Support data-binding for other than Backbone collections", "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", "closedSprints": [ { "id": 206, "state": "closed", "name": "2014 Sprint 18 Alloy", "startDate": "2014-09-02T13:23:09.065Z", "endDate": "2014-09-16T13:23:00.000Z", "completeDate": "2014-09-15T12:25:31.379Z", "originBoardId": 124 } ], "comment": { "comments": [ { "id": "320971", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Thanks for changing this to high priority... still 'd like this very much ;)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2014-08-29T06:36:31.000+0000", "updated": "2014-08-29T06:36:31.000+0000" }, { "id": "339567", "author": { "name": "medu", "key": "medu", "displayName": "me du", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I also like to have it - see my question:\r\nhttps://developer.appcelerator.com/question/180238/howto-fire-event-to-refresh-view\r\n", "updateAuthor": { "name": "medu", "key": "medu", "displayName": "me du", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-17T01:12:05.000+0000", "updated": "2015-01-17T01:12:05.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }