Permalink
Browse files

Merge branch 'master' of github.com:component/model

  • Loading branch information...
2 parents 8f7c90e + b46680e commit 1b4aba346543c0761a173add089ce4ce14674f2b @tj tj committed Jan 5, 2013
Showing with 6 additions and 4 deletions.
  1. +3 −3 lib/index.js
  2. +3 −1 lib/static.js
View
@@ -33,10 +33,10 @@ function createModel(name) {
function model(attrs) {
if (!(this instanceof model)) return new model(attrs);
+ attrs = attrs || {};
this._callbacks = {};
- this.attrs = {};
- this.dirty = {};
- if (attrs) this.set(attrs);
+ this.attrs = attrs;
+ this.dirty = attrs;
}
// mixin emitte
View
@@ -76,6 +76,8 @@ exports.attr = function(name, options){
var prev = this.attrs[name];
this.dirty[name] = val;
this.attrs[name] = val;
+ this.model.emit('change', this, name, val, prev);
+ this.model.emit('change ' + name, this, val, prev);
this.emit('change', name, val, prev);
this.emit('change ' + name, val, prev);
return this;
@@ -149,4 +151,4 @@ exports.get = function(id, fn){
function error(res) {
return new Error('got ' + res.status + ' response');
-}
+}

0 comments on commit 1b4aba3

Please sign in to comment.