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
07f88cf7
authored
2013-09-10 15:39:54 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Make sure that we unbind and re-bind any dependencies when the model changes for a binding.
1 parent
484127d0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
src/bindings.coffee
src/bindings.coffee
View file @
07f88cf
...
...
@@ -49,9 +49,9 @@ class Rivets.Binding
model
=
current
if
@
key
and
@
model
and
@
model
isnt
model
@
view
.
adapters
[
@
key
.
interface
].
unsubscribe
@
model
,
@
key
.
path
,
@
sync
@
view
.
adapters
[
@
key
.
interface
].
subscribe
model
,
@
key
.
path
,
@
sync
@
unbind
true
@
model
=
model
@
bind
true
@
sync
()
else
@
model
=
model
...
...
@@ -113,10 +113,10 @@ class Rivets.Binding
# Subscribes to the model for changes at the specified keypath. Bi-directional
# routines will also listen for changes on the element to propagate them back
# to the model.
bind
:
=>
@
binder
.
bind
?
.
call
@
,
@
el
bind
:
(
silent
=
false
)
=>
@
binder
.
bind
?
.
call
@
,
@
el
unless
silent
@
view
.
adapters
[
@
key
.
interface
].
subscribe
(
@
model
,
@
key
.
path
,
@
sync
)
if
@
key
@
sync
()
if
@
view
.
config
.
preloadData
@
sync
()
if
@
view
.
config
.
preloadData
unless
silent
if
@
options
.
dependencies
?
.
length
for
dependency
in
@
options
.
dependencies
...
...
@@ -136,8 +136,8 @@ class Rivets.Binding
@
dependencies
.
push
[
model
,
key
]
# Unsubscribes from the model and the element.
unbind
:
=>
@
binder
.
unbind
?
.
call
@
,
@
el
unbind
:
(
silent
=
false
)
=>
@
binder
.
unbind
?
.
call
@
,
@
el
unless
silent
@
view
.
adapters
[
@
key
.
interface
].
unsubscribe
(
@
model
,
@
key
.
path
,
@
sync
)
if
@
key
if
@
dependencies
.
length
...
...
Please
register
or
sign in
to post a comment