[ALOY-1480] Bug/Regression: Data binding always returns string values
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-04-24T01:31:46.000+0000 |
| Affected Version/s | Alloy 1.5.0, alloy 1.8.1, alloy 1.8.5 |
| Fix Version/s | Release 5.4.0, alloy 1.9.0, alloy 1.9.1 |
| Components | Models |
| Labels | alloy, qe-5.4.0 |
| Reporter | Andrea Vitale |
| Assignee | Fokke Zandbergen |
| Created | 2016-03-31T09:03:15.000+0000 |
| Updated | 2018-05-01T20:19:48.000+0000 |
Description
For ALOY-443 (Alloy 1.5.0) we started to use
_.template() for complex model data binding.
With ALOY-1368 and ALOY-1369 we also adopted this method for complex collection data binding.
Since _.template() always returns a string, it doesn't work for binding objects, e.g. an attributedString as the attached test case:
<Alloy>
<Collection src="source" />
<Window class="container">
<ListView id="List" defaultItemTemplate="test" top="30">
<Templates>
<ItemTemplate name="test" height="50">
<View height="Ti.UI.SIZE" layout="vertical">
<Label id="simpleTestLabel" bindId="simpleTestLabel"></Label>
<Label id="attributedTestLabel" bindId="attributedTestLabel" top="5"></Label>
</View>
</ItemTemplate>
</Templates>
<ListSection dataCollection="source" dataTransform="transform">
<ListItem simpleTestLabel:text="{simple}" attributedTestLabel:attributedString="{attributedString}"></ListItem>
</ListSection>
</ListView>
</Window>
</Alloy>
Original description
Just tested that, using alloy v1.8.2 and v1.8.5 I was unable to set theattributedString property via a ListItem template.
Using alloy 1.7.35 everything is working fine.
I attach a simple test project that contains a ListView with a template composed by two labels.
On the first label I set the text property with a simple model string and on the second one i set the attributedString.
For the first label everything is working correctly (as expected) and for the second one is working only using v1.7.35 of alloy.
Attachments
| File | Date | Size |
|---|---|---|
| attributed-string-alloy-test.zip | 2016-03-31T09:00:45.000+0000 | 10480092 |
Combined PR for ALOY-1478, ALOY-1480, ALOY-1481 and ALOY-1482: https://github.com/appcelerator/alloy/pull/780
[~bimmel] could you list this as a known issue for Alloy 1.8.5 (since that will ship with CLI 5.2.2) ?
[~fokkezb], Not a problem.
PR merged.
Verified as fixed. Tested on: iPhone 6 (9.1) iOS Simulator (9.3) Android emulator (6.0) Mac OSX El Capitan 10.11.5 Studio: 4.7.0.201607070843 Ti SDK: 5.4.0.v20160705213725 Appc NPM: 4.2.8-1 Appc CLI: 5.4.0-29 Xcode 7.3.1 Node v4.4.4 * Closing Ticket*