[ALOY-1127] Alloys Data Binding feature does not respect formFactor property
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-10-07T03:16:32.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.6.0, Alloy 1.7.0 |
Components | Models |
Labels | TCSupport, alloy |
Reporter | Jick Steen |
Assignee | Tim Poulsen |
Created | 2014-07-31T08:17:21.000+0000 |
Updated | 2015-03-26T20:53:14.000+0000 |
Description
Similar to ALOY-691 the same example fails if using the
formFactor
attribute. See following example using Alloy 1.4.1 . It results in a crash.
<Alloy>
<Collection src="test" />
<Window id="index" platform="ios" formFactor="tablet">
<View id="content" dataCollection="test" dataFunction="render">
<View></View>
</View>
</Window>
<Window id="index" platform="ios" formFactor="handheld">
<TableView>
<TableViewRow dataCollection="test" dataFunction="render">
<View></View>
</TableViewRow>
</TableView>
</Window>
</Alloy>
$.index.addEventListener('open', function () {
$.destroy();
});
$.index.open();
render();
exports.definition = {
configuration : {
"columns": {
"username":"string"
},
"adapter": {
"type": "sql",
"collection_name": "test"
},
},
extendModel: function(Model) {
_.extend(Model.prototype, {});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {});
return Collection;
}
}
This will generate the following code in destroy()
although always only one of those can be defined at a moment. To reproduce just run it on iOS.
exports.destroy = function() {
__alloyId5.off("fetch destroy change add remove reset", render);
__alloyId12.off("fetch destroy change add remove reset", render);
};
Error message will be for instance
'undefined' is not an object (evaluating '__alloyId5.off')
Link to Q&A: http://developer.appcelerator.com/question/176639/alloys-data-binding-feature-does-not-respect-handheld-property
FYI: Same error happens when using new "if" condition instead of "platform and formFactor" attribute.
[~tlukasavage]: Hello! can you please set Jick Steen as the reporter? For some reason when I move this bugs, the reporter gets changed in automatic and I can't edit them later.
I need further info to proceed. Starting with this as an example:
What should happen if the developer: - uses a different dataFunction name for each of the form factor "branches"? - uses a custom dataFunction name for one form factor, but not the other (omits
dataFunction="render"
)? - uses different UI components in the two "branches" (e.g. TableView in one, ScrollableView in the other)? And does that affect the preceding dataFunction name questions? Which of those are error conditions that should be caught vs. which need to be made to work?PR https://github.com/appcelerator/alloy/pull/580 Functional test: 1. Run the included ALOY\-1127 test app for a handset. You should get a table with blue labels in the rows. 2. Run it again for a tablet. Rows should have red labels. 3. Edit index.xml to remove or rename the dataFunction for either of the form factors (e.g. for the handheld window, change to
dataFunction="renderMe"
). Then, re-run for both form factors. In all cases, the app should run without error and display the appropriately colored rows.PR merged.
Backport to 1_6_X : https://github.com/appcelerator/alloy/pull/651
Verified fixed using: Titanium SDK 4.0.0.v20150325201813 Studio 4.0.0.201503232213 Appc NPM: 0.3.35 Appc CLI 0.2.192 Xcode 6.2 Alloy 1.6.0-alpha On: iPhone 6 Sim, iOS 8.2 iPad 2 Sim, iOS 8.2 Styling and data binding perform as expected across the two platforms.