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
ddef0dbd
authored
2012-07-07 18:24:10 +0200
by
Nicklas Ansman Giertz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Enable a way of unbinding listeners
1 parent
472cd08f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
src/rivets.coffee
src/rivets.coffee
View file @
ddef0db
...
...
@@ -26,15 +26,24 @@ class Rivets.Binding
# routines will also listen for changes on the element to propagate them back
# to the model.
bind
:
=>
Rivets
.
config
.
adapter
.
subscribe
@
model
,
@
keypath
,
(
value
)
=>
@
set
value
Rivets
.
config
.
adapter
.
subscribe
@
model
,
@
keypath
,
@
set
if
Rivets
.
config
.
preloadData
@
set
Rivets
.
config
.
adapter
.
read
@
model
,
@
keypath
if
@
type
in
bidirectionals
@
el
.
addEventListener
'change'
,
(
e
)
=>
el
=
e
.
target
or
e
.
srcElement
Rivets
.
config
.
adapter
.
publish
@
model
,
@
keypath
,
getInputValue
el
@
el
.
addEventListener
(
'change'
,
@
publish
)
publish
:
(
e
)
=>
el
=
e
.
target
or
e
.
srcElement
Rivets
.
config
.
adapter
.
publish
@
model
,
@
keypath
,
getInputValue
el
# Unsubscribes from the model and the element
unbind
:
=>
Rivets
.
config
.
adapter
.
unsubscribe
@
model
,
@
keypath
,
@
set
if
@
type
in
bidirectionals
@
el
.
removeEventListener
(
'change'
,
@
publish
)
# A collection of bindings for a parent element.
class
Rivets
.
View
...
...
@@ -144,4 +153,4 @@ rivets =
if
module
?
module
.
exports
=
rivets
else
@
rivets
=
rivets
\ No newline at end of file
@
rivets
=
rivets
...
...
Please
register
or
sign in
to post a comment