backbone.js bound events not delegated to views
When I call the save method on my model the server returns me a new version of the object from the database (even if there have been errors whilst saving).
In my model I have:
this.bind("change", function() {
console.log('CHANGED MODEL');
});
In my view I have:
this.model.bind('change', function() {
cons开发者_运维百科ole.log('CHANGED MODEL IN VIEW');
});
When I invoke the save method I only get the log from the model (CHANGED MODEL), for some reason the change event is not delegated to the view.
Am I missing something? I cannot for the life of me figure out why the change event in the view is not called when the one in the model is.
Any help is as always muchly appreciated.
It seems to me that you've forgotten to configure the view with the model:
var product = new ProductModel();
var searchView = new ProductSearchView({ model: product });
If I'm wrong, you'll have to give us more code.
精彩评论