Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : How to listen correctly to changes on a specific attribute of all model instances?

$
0
0
Usually if I need to do that, I bind it in the prototype init() for the model class.

e.g. 
  1. var Todo = can.Model.extend({
  2. findAll: 'GET /todos',
  3.     findOne: 'GET /todos/{id}',
  4. update: 'PUT /todos/{id}',
  5. destroy: 'DELETE /todos/{id}'
  6. }, {
  7.   init : function() {
  8.     this.bind("description", function() {
  9.       console.log("Yep");
  10.     });
  11.   }
  12. });

Viewing all articles
Browse latest Browse all 3491

Trending Articles