backbone.epoxy icon indicating copy to clipboard operation
backbone.epoxy copied to clipboard

Nested model bindings

Open houpli opened this issue 10 years ago • 1 comments

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 !

houpli avatar Jun 12 '15 09:06 houpli

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'

mjnikkila avatar Jun 24 '15 08:06 mjnikkila