Can I listen to any changes in one object in Model? I know how to listen model changes, but I need only to listen objects in model and view.
var view = Backbone.View.extend({
func: {},
initialize: function () {
this.listenTo(this.func, 'change', function(select){
console.log(select.changed) //NEED TO SHOW ON ADDING ANY DATA TO this.func
})
this.func['asd'] = 'asdasd';
}
})
This is exactly what models are for - not just fetching data from a server but also passing data around your app.
When you want to be informed about changes to some data you don't create a custom variable you use attributes.
Fiddle: http://fiddle.jshell.net/ferahl/4fxtZ/
you can listen to model's change event using