backbone.js - Listen to attribute changes in a backbone view -


I want to call a method in my view when its attributes Gives me an error: There is no undefined function .

  SimpleView = Backbone.View.extend ({initialize: function () {this.attributes = _.extend (this.attributes, Backbone.Events); // update this.attributes.on ('change', this.updateAttributes (), this);}});   

Update: I thought I have attributes with backbone.Events so that I can hear the changes. Yes ... so now I do not get any more errors, but still nothing happens. Any help would be greatly appreciated.

Although I recommend you to use a model to keep attributes, If you want to be with the current perspective, then you have to manually trigger the event.

  this.attributes.trigger ('change');   

I have made your updates so that you can get an idea of ​​how it can work.

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

c# - Call function from DLL -