gmac / backbone.epoxy

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

Nested model bindings #122

Open houpli opened 9 years ago

houpli commented 9 years ago

Hi,

I have this model : { a: "value1", b: "value2", nestedModel: (Backbone.Model) { c: "value3", d: "value4" } }

How bind the main model and the nested model into the same view ?

I can't access to the nested model in the bindingSources declaration :(

Thank you !

mjnikkila commented 9 years ago

I pretty much need this feature too. There is way around though. You need to use bindingSources to bind into nested model.

Like this bindingSources: function() { return { nestedModel: function () { return this.model.get("nestedModel"); }.bind(this) } }

Don't forget to add: _.bindAll(this, "bindingSources"); in constructor.

Then access in binding: '#foo': 'text: nestedModel_attribute'