[ALOY-691] Alloys Data Binding feature does not respect platform property
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-05-22T15:50:18.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.4.0 |
Components | Models |
Labels | alloy, qe-testadded |
Reporter | Jick Steen |
Assignee | Tim Poulsen |
Created | 2013-06-05T16:12:08.000+0000 |
Updated | 2014-05-23T17:32:41.000+0000 |
Description
Hi,
when using data binding on an element limited to a specific platform, the data function will be created twice. After compiling the example below you will notice the created resource contains two render functions. The render function for iOS and MobileWeb overwrites the function for Android. Calling $.destroy() might break on iOS because the Android related collection is not defined.
Link to Q&A: http://developer.appcelerator.com/question/153195/alloys-data-binding-feature-does-not-respect-platform-property
View:
<Alloy>
<Collection src="test" />
<Window id="index">
<View id="content" dataCollection="test" dataFunction="render" platform="android">
<View></View>
</View>
<TableView id="content" dataCollection="test" dataFunction="render" platform="ios,mobileweb">
<TableViewRow>
<View></View>
</TableViewRow>
</TableView>
</Window>
</Alloy>
Controller:
$.index.open();
render();
$.destroy();
Model:
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;
}
}
PR: https://github.com/appcelerator/alloy/pull/339 Functional test: Using either the sample code provided in the ticket above or in the test app ALOY-691, build the app. Only one copy of render() is included in the generated code.
PR: https://github.com/appcelerator/alloy/pull/342
Reopening as for android I am seeing two copies of render() in the generated code. On iOS & mobileweb, only one copy of render() is seen. Code generated for android:
Environment: Appc Studio : 3.3.0.201405121247 Ti SDK : 3.3.0.v20140514163013 Mac OSX : 10.8.5 Alloy : 1.4.0-alpha CLI - 3.3.0-dev Nexus 5 - android 4.4.2
New PR https://github.com/appcelerator/alloy/pull/401 submitted and merged
Reopening because my last implementation didn't work properly when an element was tagged to support multiple platforms.
New PR https://github.com/appcelerator/alloy/pull/410 Merged to 1_4_X and master Properly prevents the processing of children (e.g. TableViewRows) of tags not for the current platform (e.g. TableView). Test app https://github.com/appcelerator/alloy/tree/master/test/apps/testing/ALOY-691
Verified fixed and working as expected with the latest sample code and fix. Closing. TiSDK 3.3.0.v20140522110830 Alloy 1.4.0-alpha4 Appcelerator Studio 3.3.0.201405211748 CLI 3.3.0-alpha5 iOS Compiled code :
Android Compiled code: