Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
26981461
authored
2012-09-03 13:24:05 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Move the bidirectional binding check into it's own function.
1 parent
791a4bcc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
src/rivets.coffee
src/rivets.coffee
View file @
2698146
...
...
@@ -23,9 +23,11 @@ class Rivets.Binding
@
formatters
=
@
options
.
formatters
||
[]
# Bindings that should also observe the DOM element for changes in order to
# propagate those changes back to the model object.
bidirectionals
:
[
'value'
,
'checked'
,
'unchecked'
]
# Returns true|false depending on whether or not the binding should also
# observe the DOM element for changes in order to propagate those changes
# back to the model object.
isBidirectional
:
=>
@
type
in
[
'value'
,
'checked'
,
'unchecked'
]
# Applies all the current formatters to the supplied value and returns the
# formatted value.
...
...
@@ -77,7 +79,7 @@ class Rivets.Binding
for
keypath
in
@
options
.
dependencies
Rivets
.
config
.
adapter
.
subscribe
@
model
,
keypath
,
@
sync
if
@
type
in
@
bidirectionals
if
@
isBidirectional
()
bindEvent
@
el
,
'change'
,
@
publish
# Publishes the value currently set on the input element back to the model.
...
...
@@ -94,7 +96,7 @@ class Rivets.Binding
for
keypath
in
@
options
.
dependencies
Rivets
.
config
.
adapter
.
unsubscribe
@
model
,
keypath
,
@
sync
if
@
type
in
@
bidirectionals
if
@
isBidirectional
()
@
el
.
removeEventListener
'change'
,
@
publish
# A collection of bindings built from a set of parent elements.
...
...
Please
register
or
sign in
to post a comment