[ALOY-476] Widgets within model-bound view get bound to unexisting $model
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2013-01-24T20:44:06.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.0.0, 2013 Sprint 02 |
Components | Widgets |
Labels | alloy, bind, bindings, model, view, widgets |
Reporter | Fokke Zandbergen |
Assignee | Unknown |
Created | 2013-01-21T19:41:46.000+0000 |
Updated | 2018-03-07T22:25:48.000+0000 |
Description
This:
<Alloy>
<Collection src="tip" />
<Window>
<TableView id="table" dataCollection="tip">
<TableViewRow class="row" >
<Widget src="nl.fokkezb.cachedImageView" id="profileImageView" image="{image}" />
<Label class="rowTitle" text="{name}"/>
</TableViewRow>
</TableView>
</Window>
</Alloy>
Results in the following binding callback:
var __alloyId10 = function(e) {
var models = Alloy.Collections.tip.models, len = models.length, rows = [];
for (var i = 0; i < len; i++) {
var __alloyId5 = models[i];
__alloyId5.__transform = {};
var __alloyId6 = A$(Ti.UI.createTableViewRow({
id: "__alloyId4"
}), "TableViewRow", null);
rows.push(__alloyId6);
var __alloyId7 = Alloy.createWidget("nl.fokkezb.cachedImageView", "widget", {
id: "profileImageView",
image: typeof $model.__transform.image != "undefined" ? $model.__transform.image : $model.get("image"),
$model: __alloyId5
});
__alloyId7.setParent(__alloyId6);
var __alloyId9 = A$(Ti.UI.createLabel({
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000",
text: typeof __alloyId5.__transform.name != "undefined" ? __alloyId5.__transform.name : __alloyId5.get("name"),
id: "__alloyId8"
}), "Label", __alloyId6);
__alloyId6.add(__alloyId9);
}
$.__views.table.setData(rows);
};
Leading to:
[ERROR] Script Error = 'null' is not an object (evaluating '$model.__transform') at index.js (line 25).
Note the difference between lines 12 and 20 of the callback. It looks like $model
must be __alloyId5
in this specific case, since that refers to the model.
No comments