Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Binding model data that contains child nodes

$
0
0

In a ListItem, I would like to bind data like this:

<ListItem pic:image="{presenter.imageurl}" />
where the dataCollection looks like this:
Alloy.Collections.presentations = new Backbone.Collection();
Alloy.Collections.presentations.reset([
    {
        title:'How To Train Your Dragon',
        scheduledDate: '05/01/2014',
        presenter: {
            firstname: 'Hiccup',
            lastname: 'Horrendous',
            imageurl: '/presenter/hiccup.jpg'
        },
        capacity: 100
    },
    {
        title:'Assembler For Dummies',
        scheduledDate: '05/08/2014',
        presenter: {
            firstname: 'Michael',
            lastname: 'Macro',
            imageurl: '/presenter/macro.jpg'
        },
        capacity: 50
    }
]);
My workaround right now is to implement a dataTransform callback and hack this in:
function doTransform(model) {
    var transform = model.toJSON();
    transform.presenter_imageurl = transform.presenter.imageurl;
    return transform;
}
With the ListItem that looks like this:
<ListItem pic:image="{presenter_imageurl}" />
Are there better ways to achieve this? Appreciate the help.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>