Build 0.3.12.
Showing
4 changed files
with
21 additions
and
17 deletions
1 | // rivets.js | 1 | // rivets.js |
2 | // version: 0.3.11 | 2 | // version: 0.3.12 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -90,7 +90,7 @@ | ... | @@ -90,7 +90,7 @@ |
90 | }; | 90 | }; |
91 | 91 | ||
92 | Binding.prototype.bind = function() { | 92 | Binding.prototype.bind = function() { |
93 | var dependency, keypath, model, _i, _len, _ref, _ref1; | 93 | var dependency, keypath, model, _i, _len, _ref, _ref1, _results; |
94 | if (this.options.bypass) { | 94 | if (this.options.bypass) { |
95 | this.sync(); | 95 | this.sync(); |
96 | } else { | 96 | } else { |
... | @@ -98,9 +98,13 @@ | ... | @@ -98,9 +98,13 @@ |
98 | if (Rivets.config.preloadData) { | 98 | if (Rivets.config.preloadData) { |
99 | this.sync(); | 99 | this.sync(); |
100 | } | 100 | } |
101 | if (this.isBidirectional()) { | ||
102 | bindEvent(this.el, 'change', this.publish); | ||
103 | } | ||
101 | } | 104 | } |
102 | if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) { | 105 | if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) { |
103 | _ref1 = this.options.dependencies; | 106 | _ref1 = this.options.dependencies; |
107 | _results = []; | ||
104 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | 108 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { |
105 | dependency = _ref1[_i]; | 109 | dependency = _ref1[_i]; |
106 | if (/^\./.test(dependency)) { | 110 | if (/^\./.test(dependency)) { |
... | @@ -111,29 +115,29 @@ | ... | @@ -111,29 +115,29 @@ |
111 | model = this.view.models[dependency.shift()]; | 115 | model = this.view.models[dependency.shift()]; |
112 | keypath = dependency.join('.'); | 116 | keypath = dependency.join('.'); |
113 | } | 117 | } |
114 | Rivets.config.adapter.subscribe(model, keypath, this.sync); | 118 | _results.push(Rivets.config.adapter.subscribe(model, keypath, this.sync)); |
115 | } | 119 | } |
116 | } | 120 | return _results; |
117 | if (this.isBidirectional()) { | ||
118 | return bindEvent(this.el, 'change', this.publish); | ||
119 | } | 121 | } |
120 | }; | 122 | }; |
121 | 123 | ||
122 | Binding.prototype.unbind = function() { | 124 | Binding.prototype.unbind = function() { |
123 | var keypath, _i, _len, _ref, _ref1; | 125 | var keypath, _i, _len, _ref, _ref1, _results; |
124 | if (!this.options.bypass) { | 126 | if (!this.options.bypass) { |
125 | Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.sync); | 127 | Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.sync); |
126 | if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) { | ||
127 | _ref1 = this.options.dependencies; | ||
128 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
129 | keypath = _ref1[_i]; | ||
130 | Rivets.config.adapter.unsubscribe(this.model, keypath, this.sync); | ||
131 | } | ||
132 | } | ||
133 | if (this.isBidirectional()) { | 128 | if (this.isBidirectional()) { |
134 | return this.el.removeEventListener('change', this.publish); | 129 | unbindEvent(this.el('change', this.publish)); |
135 | } | 130 | } |
136 | } | 131 | } |
132 | if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) { | ||
133 | _ref1 = this.options.dependencies; | ||
134 | _results = []; | ||
135 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
136 | keypath = _ref1[_i]; | ||
137 | _results.push(Rivets.config.adapter.unsubscribe(this.model, keypath, this.sync)); | ||
138 | } | ||
139 | return _results; | ||
140 | } | ||
137 | }; | 141 | }; |
138 | 142 | ||
139 | return Binding; | 143 | return Binding; | ... | ... |
This diff is collapsed.
Click to expand it.
1 | { | 1 | { |
2 | "name" : "rivets", | 2 | "name" : "rivets", |
3 | "description" : "Declarative data binding facility.", | 3 | "description" : "Declarative data binding facility.", |
4 | "version" : "0.3.11", | 4 | "version" : "0.3.12", |
5 | "author" : "Michael Richards", | 5 | "author" : "Michael Richards", |
6 | "url" : "http://rivetsjs.com", | 6 | "url" : "http://rivetsjs.com", |
7 | "main" : "./lib/rivets.js", | 7 | "main" : "./lib/rivets.js", | ... | ... |
-
Please register or sign in to post a comment