Bind sub-model to view in backbone / marionette


I have a User model that has a BankAccount model and I have view who's model attribute is set to the User model and in that view's template I reference an attribute of the bank account:

<%= bankAccount.get('description') || 'No linked account' %>

If I updated the bankAccount the view doesn't pick up on the change:

user.get('bankAccount').set('description', 'foobar')

I tried adding the following in the initialize on the User model but it didn't work either.

initialize: function() {
  var self = this;

  this.on('change:bankAccount', function() {
    self.get('bankAccount').bind('change', function() {

Any suggestions? Also, both these models use backbone relational, if that helps.


From the Backbone-relational Events you will see that you can bind to update:

This video can help you solving your question :)
By: admin