gmac / backbone.epoxy

Declarative data binding and computed models for Backbone
http://epoxyjs.org
MIT License
615 stars 89 forks source link

How to return array from bindingSources? #128

Closed victorwpbastos closed 8 years ago

victorwpbastos commented 8 years ago

Something like this:

bindingSources: {
    ages: [10, 20, 30, 40, 50]
}

Or:

bindingSources: {
    ages: [
        {label: 10, value: 10},
        {label: 20, value: 20},
        {label: 30, value: 30},
        {label: 40, value: 40},
        {label: 50, value: 50}
    ]
}

Or:

bindingSources: {
    ages: function() { return [
            {label: 10, value: 10},
            {label: 20, value: 20},
            {label: 30, value: 30},
            {label: 40, value: 40},
            {label: 50, value: 50}
        ]
    }
}

I tried all of them but without success :disappointed:

etal2 commented 8 years ago

binding sources expect models or collections, try:

    bindingSources: {
       ages: new Backbone.Collection([
            {label: 10, value: 10},
            {label: 20, value: 20},
            {label: 30, value: 30},
            {label: 40, value: 40},
            {label: 50, value: 50}
        ]);
    }