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

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -