In a ResthubView, one might have the following code:
initialize: function() {
this.listenTo(this.collection,'change', _.bind(this.render,this));
}
This allows the view to be re-rendered when a model attribute changes. As designed by Backbone, the render method will be called with the modified model as parameter.
The problem is that ResthubView.render assume that first param is the context object. In the above situation, it should be a Collection but render is called with a Model instance due to Backbone design. It results in strange behavior when context is JSONified.
A quick workaround is to explicitly call renderwith no argument:
initialize: function() {
this.listenTo(this.collection,'change', _.bind(function(){
this.render();
},this));
},
In a ResthubView, one might have the following code:
This allows the view to be re-rendered when a model attribute changes. As designed by Backbone, the
rendermethod will be called with the modified model as parameter.The problem is that
ResthubView.renderassume that first param is thecontextobject. In the above situation, it should be aCollectionbutrenderis called with aModelinstance due to Backbone design. It results in strange behavior when context is JSONified.A quick workaround is to explicitly call
renderwith no argument: