[ALOY-489] Allow developers to specify an explicit function name for autogen binding function
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-07-12T21:10:38.000+0000 |
Affected Version/s | Alloy 1.0.0 |
Fix Version/s | Alloy 1.1.0, 2013 Sprint 04 |
Components | Runtime |
Labels | qe-testadded |
Reporter | Tony Lukasavage |
Assignee | Tony Lukasavage |
Created | 2013-01-28T18:41:07.000+0000 |
Updated | 2013-07-12T21:10:38.000+0000 |
Description
Alloy currently uses an under-the-hood unique variable name for any binding functions used for collection binding. For example, here's some markup and its generated binding code:
<TableView id="table" dataCollection="myModel">
<Require src="row"/>
</TableView>
var __alloyId19 = function(e) {
var models = Alloy.Collections.myModel.models, len = models.length, rows = [];
for (var i = 0; i < len; i++) {
var __alloyId17 = models[i];
__alloyId17.__transform = {};
var __alloyId18 = Alloy.createController("row", {
id: "__alloyId15",
$model: __alloyId17
});
rows.push(__alloyId18.getViewEx({
recurse: !0
}));
}
$.__views.table.setData(rows);
};
It would be beneficial to developers to have direct access to that function so that they can trigger the binding themselves. This would be useful in cases where perhaps local filtering was being performed on a collection but the developer didn't actually want to modify or fetch the collection, they just want the UI to reflect the filtering. It would look like this:
<TableView id="table" dataCollection="myModel" dataFunction="myBindingFunction">
<Require src="row"/>
</TableView>
and then a developer could directly call this function in their own controller when they wanted to execute the binding code:
myBindingFunction();
dataFunction attribute let's you specify an explicit function for data binding that can be called in the controller as specified above. THe test app for it can be found here: https://github.com/appcelerator/alloy/tree/master/test/apps/models/binding_dataFunction
Reopening for changing labels