Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested model bindings #122

Open
houpli opened this issue Jun 12, 2015 · 1 comment
Open

Nested model bindings #122

houpli opened this issue Jun 12, 2015 · 1 comment

Comments

@houpli
Copy link

houpli commented Jun 12, 2015

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
Copy link

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants