Only listen for changes on model in routine()
Showing
1 changed file
with
11 additions
and
7 deletions
... | @@ -53,9 +53,9 @@ define(['rivets', 'bootstrap'], function(rivets) { | ... | @@ -53,9 +53,9 @@ define(['rivets', 'bootstrap'], function(rivets) { |
53 | $(holder.container).removeClass('focused'); | 53 | $(holder.container).removeClass('focused'); |
54 | }, | 54 | }, |
55 | blur: function() { | 55 | blur: function() { |
56 | holder.lastObj.seen(holder.lastId, true); | 56 | if (holder.lastObj) holder.lastObj.seen(holder.lastId, true); |
57 | $(holder.container).addClass('focused'); | 57 | $(holder.container).addClass('focused'); |
58 | holder.lastObj.validate(); | 58 | if (holder.lastObj) holder.lastObj.validate(); |
59 | }, | 59 | }, |
60 | validated: function(isValid, model, errors) { | 60 | validated: function(isValid, model, errors) { |
61 | var errorList = errors[holder.lastId]; | 61 | var errorList = errors[holder.lastId]; |
... | @@ -69,11 +69,6 @@ define(['rivets', 'bootstrap'], function(rivets) { | ... | @@ -69,11 +69,6 @@ define(['rivets', 'bootstrap'], function(rivets) { |
69 | } | 69 | } |
70 | } | 70 | } |
71 | }; | 71 | }; |
72 | diveIntoObject(this.observer.target, this.observer.key.path, function(obj, id) { | ||
73 | holder.lastObj = obj; | ||
74 | holder.lastId = id; | ||
75 | obj.on('validated', holder.validated); | ||
76 | }); | ||
77 | $(el).on('focus', holder.focus).on('blur', holder.blur); | 72 | $(el).on('focus', holder.focus).on('blur', holder.blur); |
78 | rivetsBinderCall(this, this.args[0], 'bind', arguments); | 73 | rivetsBinderCall(this, this.args[0], 'bind', arguments); |
79 | }, | 74 | }, |
... | @@ -88,6 +83,15 @@ define(['rivets', 'bootstrap'], function(rivets) { | ... | @@ -88,6 +83,15 @@ define(['rivets', 'bootstrap'], function(rivets) { |
88 | rivetsBinderCall(this, this.args[0], 'unbind', arguments); | 83 | rivetsBinderCall(this, this.args[0], 'unbind', arguments); |
89 | }, | 84 | }, |
90 | routine: function(el, value) { | 85 | routine: function(el, value) { |
86 | var holder = this.validationHolder; | ||
87 | if (holder.lastObj) { | ||
88 | holder.lastObj.off('validated', holder.validated); | ||
89 | } | ||
90 | diveIntoObject(this.observer.target, this.observer.key.path, function(obj, id) { | ||
91 | holder.lastObj = obj; | ||
92 | holder.lastId = id; | ||
93 | obj.on('validated', holder.validated); | ||
94 | }); | ||
91 | rivetsBinderCall(this, this.args[0], 'routine', arguments); | 95 | rivetsBinderCall(this, this.args[0], 'routine', arguments); |
92 | } | 96 | } |
93 | }; | 97 | }; | ... | ... |
-
Please register or sign in to post a comment