Binding To ItemView the change Events


I would like to re-render a list made using Marionette.ItemView
when the corresponding model in ItemView change.

Any idea about the best way to active this task?

// Collection passed to Marionette.CompositeView
myCollection.attributes = [
        id: 1,
        name: 'bar'
        closed: false

// Marionette.ItemView
    closed: true
}); // when this model change I would like to re-render the copositeView 
    // or remove the Marionette.ItemView

If I try the following code(1) in Marionette.ItemView,
when I save the model, I get the following error(2).


// Marionette.ItemView
initialize: function () {
    this.model.on('change', this.render);


Uncaught TypeError: Object [object Object] has no method 'serializeData'


Is a good practice to use the _.bindAll in your initialize method. May be your issue is related to the scope.

initialize: function () {
    this.model.on('change', this.render);

If bindAll does not fix your issue please paste your Model and View.

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