Implement a select function instead of preset selects like bidirectionals.
Showing
1 changed file
with
4 additions
and
3 deletions
... | @@ -178,8 +178,9 @@ class Rivets.View | ... | @@ -178,8 +178,9 @@ class Rivets.View |
178 | parseNode node for node in el.getElementsByTagName '*' | 178 | parseNode node for node in el.getElementsByTagName '*' |
179 | return | 179 | return |
180 | 180 | ||
181 | bidirectionals: => | 181 | # Returns an array of bindings where the supplied function evaluates to true. |
182 | binding for binding in @bindings when binding.isBidirectional() | 182 | select: (fn) => |
183 | binding for binding in @bindings when fn binding | ||
183 | 184 | ||
184 | # Binds all of the current bindings for this view. | 185 | # Binds all of the current bindings for this view. |
185 | bind: => | 186 | bind: => |
... | @@ -193,7 +194,7 @@ class Rivets.View | ... | @@ -193,7 +194,7 @@ class Rivets.View |
193 | binding.sync() for binding in @bindings | 194 | binding.sync() for binding in @bindings |
194 | 195 | ||
195 | publish: => | 196 | publish: => |
196 | binding.publish() for binding in @bidirectionals() | 197 | binding.publish() for binding in @select (b) -> b.isBidirectional() |
197 | 198 | ||
198 | # Cross-browser event binding | 199 | # Cross-browser event binding |
199 | bindEvent = (el, event, fn) -> | 200 | bindEvent = (el, event, fn) -> | ... | ... |
-
Please register or sign in to post a comment