Titanium JIRA Archive
Alloy (ALOY)

[ALOY-489] Allow developers to specify an explicit function name for autogen binding function

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-12T21:10:38.000+0000
Affected Version/sAlloy 1.0.0
Fix Version/sAlloy 1.1.0, 2013 Sprint 04
ComponentsRuntime
Labelsqe-testadded
ReporterTony Lukasavage
AssigneeTony Lukasavage
Created2013-01-28T18:41:07.000+0000
Updated2013-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();

Comments

  1. Tony Lukasavage 2013-02-14

    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
  2. Federico Casali 2013-07-12

    Reopening for changing labels

JSON Source