ca62b8b1 by Adam Heath

The binding.observer never changes after the .bind call, so move the

'capture' of that in holder to the bind method.
1 parent cae155ef
......@@ -34,23 +34,25 @@ define(function(require) {
rivets.binders['error-*'] = {
bind: function(el) {
var observer = this.observer;
var holder = this.validationHolder = {
//marker: el.parentNode.insertBefore(document.createComment(" rivets: " + this.type + " "), el),
observer: observer,
focus: function() {
render(el, 'focus', false);
},
blur: function() {
if (holder.observer && holder.observer.target) {
holder.observer.target.seen(holder.observer.key.path, true);
if (observer.target) {
observer.target.seen(observer.key.path, true);
}
render(el, 'blur', false);
if (holder.observer && holder.observer.target) {
holder.observer.target.validate();
if (observer.target) {
observer.target.validate();
}
},
validated: function(isValid, model, errors) {
var errorList = errors[holder.observer.key.path];
if (errorList && holder.observer.target && holder.observer.target.seen(holder.observer.key.path)) {
var errorList = errors[observer.key.path];
if (errorList && observer.target && observer.target.seen(holder.observer.key.path)) {
render(el, 'validated', errorList);
} else {
render(el, 'validated', false);
......@@ -74,10 +76,9 @@ define(function(require) {
},
routine: function() {
var holder = this.validationHolder;
if (holder.observer) {
holder.observer.target.off('validated', holder.validated);
if (this.observer.target) {
this.observer.target.off('validated', holder.validated);
}
holder.observer = this.observer;
if (this.observer.target) {
this.observer.target.on('validated', holder.validated);
}
......