{ "id": "111044", "key": "ALOY-563", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "14634", "description": "Alloy 1.0.0", "name": "Alloy 1.0.0", "archived": false, "released": true, "releaseDate": "2013-02-19" }, { "id": "14873", "description": "2013 Sprint 04", "name": "2013 Sprint 04", "archived": true, "released": true, "releaseDate": "2013-02-25" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-03-30T14:10:46.000+0000", "created": "2013-03-12T11:38:40.000+0000", "priority": null, "labels": [ "alloy", "alloy-generate" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-03-07T22:25:46.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": [], "description": "A repetition view that is bound to a global collection is not initialized to the contents of the collection upon creation. Consider the following snippet:\r\n\r\n{code}\r\n\r\n \r\n\r\n{code}\r\n\r\nThe autogenerated initialization code for this piece looks like this:\r\n\r\n{code}\r\nvar __alloyId31 = function(e) {\r\n var models = filterDocuments(Alloy.Collections.document), children = $.__views.documentsContainer.children;\r\n for (var d = children.length - 1; d >= 0; d--) $.__views.documentsContainer.remove(children[d]);\r\n len = models.length;\r\n for (var i = 0; i < len; i++) {\r\n var __alloyId28 = models[i];\r\n __alloyId28.__transform = {};\r\n var __alloyId30 = Alloy.createController(\"indexdocumentrow\", {\r\n notClickable: \"0\",\r\n id: \"__alloyId29\",\r\n $model: __alloyId28\r\n });\r\n __alloyId30.setParent($.__views.documentsContainer);\r\n }\r\n };\r\n Alloy.Collections.document.on(\"fetch destroy change add remove reset\", __alloyId31);\r\n{code}\r\n\r\nTo have this repeater view initialize, I need to either fetch the collection (which is already done at the beginning of the app) or fire one of the events from the last line, which is more suitable and which is what I do:\r\n\r\n{code}\r\nAlloy.Collections.document.trigger(\"change\");\r\n{code}\r\n\r\nThe problem now is, when I fire this event, all listeners in all open windows get this event. This means that all views in every window are first getting removed and then initialized again. This leads to enormous lagging.\r\n\r\nAs for me, there must be a markup attribute or another means to initialize the collection right upon creation, this would make it logical.\r\n\r\nSee original discussion: https://developer.appcelerator.com/question/149192/initialization-of-a-repeater-view-with-databinding", "attachment": [], "flagged": false, "summary": "Allow for autoinitialization of Alloy repetition views from global collections on creation", "creator": { "name": "a.chirikba", "key": "a.chirikba", "displayName": "Andrey Chirikba", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Any", "comment": { "comments": [ { "id": "244644", "author": { "name": "a.chirikba", "key": "a.chirikba", "displayName": "Andrey Chirikba", "active": true, "timeZone": "Europe/Berlin" }, "body": "I would suggest at least making the initialization function (currently an autogenerated name) accessible to user-written code. This would mean we can call it upon controller initialization without resorting to faking events. This would also help the user to reinitialize the view on events other than the default ones.", "updateAuthor": { "name": "a.chirikba", "key": "a.chirikba", "displayName": "Andrey Chirikba", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-03-29T13:16:33.000+0000", "updated": "2013-03-29T13:16:33.000+0000" }, { "id": "244752", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Not exactly a duplicate, but this is actually resolved by ALOY-489. You can use the new {{dataFunction}} attribute to give an explicit name to the binding function.\r\n\r\nh3. index.xml\r\n\r\n{code:xml}\r\n\r\n \r\n \r\n \r\n\r\n{code}\r\n\r\nh3. index.js\r\n\r\n{code:javascript}\r\n// fire binding manually\r\ndoBinding();\r\n{code}", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-03-30T14:10:46.000+0000", "updated": "2013-03-30T14:11:06.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }