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) { ...@@ -34,23 +34,25 @@ define(function(require) {
34 34
35 rivets.binders['error-*'] = { 35 rivets.binders['error-*'] = {
36 bind: function(el) { 36 bind: function(el) {
37 var observer = this.observer;
37 var holder = this.validationHolder = { 38 var holder = this.validationHolder = {
38 //marker: el.parentNode.insertBefore(document.createComment(" rivets: " + this.type + " "), el), 39 //marker: el.parentNode.insertBefore(document.createComment(" rivets: " + this.type + " "), el),
40 observer: observer,
39 focus: function() { 41 focus: function() {
40 render(el, 'focus', false); 42 render(el, 'focus', false);
41 }, 43 },
42 blur: function() { 44 blur: function() {
43 if (holder.observer && holder.observer.target) { 45 if (observer.target) {
44 holder.observer.target.seen(holder.observer.key.path, true); 46 observer.target.seen(observer.key.path, true);
45 } 47 }
46 render(el, 'blur', false); 48 render(el, 'blur', false);
47 if (holder.observer && holder.observer.target) { 49 if (observer.target) {
48 holder.observer.target.validate(); 50 observer.target.validate();
49 } 51 }
50 }, 52 },
51 validated: function(isValid, model, errors) { 53 validated: function(isValid, model, errors) {
52 var errorList = errors[holder.observer.key.path]; 54 var errorList = errors[observer.key.path];
53 if (errorList && holder.observer.target && holder.observer.target.seen(holder.observer.key.path)) { 55 if (errorList && observer.target && observer.target.seen(holder.observer.key.path)) {
54 render(el, 'validated', errorList); 56 render(el, 'validated', errorList);
55 } else { 57 } else {
56 render(el, 'validated', false); 58 render(el, 'validated', false);
...@@ -74,10 +76,9 @@ define(function(require) { ...@@ -74,10 +76,9 @@ define(function(require) {
74 }, 76 },
75 routine: function() { 77 routine: function() {
76 var holder = this.validationHolder; 78 var holder = this.validationHolder;
77 if (holder.observer) { 79 if (this.observer.target) {
78 holder.observer.target.off('validated', holder.validated); 80 this.observer.target.off('validated', holder.validated);
79 } 81 }
80 holder.observer = this.observer;
81 if (this.observer.target) { 82 if (this.observer.target) {
82 this.observer.target.on('validated', holder.validated); 83 this.observer.target.on('validated', holder.validated);
83 } 84 }
......