5a5b030e by Ean Schuessler

Only listen for changes on model in routine()

1 parent eef0b67c
......@@ -53,9 +53,9 @@ define(['rivets', 'bootstrap'], function(rivets) {
$(holder.container).removeClass('focused');
},
blur: function() {
holder.lastObj.seen(holder.lastId, true);
if (holder.lastObj) holder.lastObj.seen(holder.lastId, true);
$(holder.container).addClass('focused');
holder.lastObj.validate();
if (holder.lastObj) holder.lastObj.validate();
},
validated: function(isValid, model, errors) {
var errorList = errors[holder.lastId];
......@@ -69,11 +69,6 @@ define(['rivets', 'bootstrap'], function(rivets) {
}
}
};
diveIntoObject(this.observer.target, this.observer.key.path, function(obj, id) {
holder.lastObj = obj;
holder.lastId = id;
obj.on('validated', holder.validated);
});
$(el).on('focus', holder.focus).on('blur', holder.blur);
rivetsBinderCall(this, this.args[0], 'bind', arguments);
},
......@@ -88,6 +83,15 @@ define(['rivets', 'bootstrap'], function(rivets) {
rivetsBinderCall(this, this.args[0], 'unbind', arguments);
},
routine: function(el, value) {
var holder = this.validationHolder;
if (holder.lastObj) {
holder.lastObj.off('validated', holder.validated);
}
diveIntoObject(this.observer.target, this.observer.key.path, function(obj, id) {
holder.lastObj = obj;
holder.lastId = id;
obj.on('validated', holder.validated);
});
rivetsBinderCall(this, this.args[0], 'routine', arguments);
}
};
......