Fix typo in object iteration. Add conditional when setting the binder data (conf…
…ig option for preloadData).
Showing
2 changed files
with
10 additions
and
6 deletions
... | @@ -33,7 +33,10 @@ | ... | @@ -33,7 +33,10 @@ |
33 | Binding.prototype.bind = function() { | 33 | Binding.prototype.bind = function() { |
34 | var _ref, | 34 | var _ref, |
35 | _this = this; | 35 | _this = this; |
36 | this.set() && this.adapter.subscribe(this.context, this.keypath, function(value) { | 36 | if (Rivets.config.preloadData) { |
37 | this.set(); | ||
38 | } | ||
39 | this.adapter.subscribe(this.context, this.keypath, function(value) { | ||
37 | return _this.set(value); | 40 | return _this.set(value); |
38 | }); | 41 | }); |
39 | if (_ref = this.type, __indexOf.call(bidirectionals, _ref) >= 0) { | 42 | if (_ref = this.type, __indexOf.call(bidirectionals, _ref) >= 0) { |
... | @@ -113,13 +116,13 @@ | ... | @@ -113,13 +116,13 @@ |
113 | 116 | ||
114 | rivets = { | 117 | rivets = { |
115 | configure: function(options) { | 118 | configure: function(options) { |
116 | var property, value, _i, _len, _results; | 119 | var property, value, _results; |
117 | if (options == null) { | 120 | if (options == null) { |
118 | options = {}; | 121 | options = {}; |
119 | } | 122 | } |
120 | _results = []; | 123 | _results = []; |
121 | for (value = _i = 0, _len = options.length; _i < _len; value = ++_i) { | 124 | for (property in options) { |
122 | property = options[value]; | 125 | value = options[property]; |
123 | _results.push(Rivets.config[property] = value); | 126 | _results.push(Rivets.config[property] = value); |
124 | } | 127 | } |
125 | return _results; | 128 | return _results; | ... | ... |
... | @@ -18,7 +18,8 @@ class Rivets.Binding | ... | @@ -18,7 +18,8 @@ class Rivets.Binding |
18 | # Conditionally also does the inverse and listens to the element for changes | 18 | # Conditionally also does the inverse and listens to the element for changes |
19 | # to propogate back to the context object. | 19 | # to propogate back to the context object. |
20 | bind: => | 20 | bind: => |
21 | @set() and @adapter.subscribe @context, @keypath, (value) => @set value | 21 | @set() if Rivets.config.preloadData |
22 | @adapter.subscribe @context, @keypath, (value) => @set value | ||
22 | 23 | ||
23 | if @type in bidirectionals | 24 | if @type in bidirectionals |
24 | @el.addEventListener 'change', (el) => | 25 | @el.addEventListener 'change', (el) => |
... | @@ -79,7 +80,7 @@ Rivets.config = | ... | @@ -79,7 +80,7 @@ Rivets.config = |
79 | # binding routines and bind contexts to DOM elements. | 80 | # binding routines and bind contexts to DOM elements. |
80 | rivets = | 81 | rivets = |
81 | configure: (options={}) -> | 82 | configure: (options={}) -> |
82 | for property, value in options | 83 | for property, value of options |
83 | Rivets.config[property] = value | 84 | Rivets.config[property] = value |
84 | 85 | ||
85 | register: (routine, routineFunction) -> | 86 | register: (routine, routineFunction) -> | ... | ... |
-
Please register or sign in to post a comment