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
47931082
authored
2013-07-13 18:35:28 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Implement Rivets.TextBinding to building text node bindings.
1 parent
9996435f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
src/rivets.coffee
src/rivets.coffee
View file @
4793108
...
...
@@ -207,6 +207,26 @@ class Rivets.ComponentBinding extends Rivets.Binding
unbind
:
=>
@
componentView
?
.
unbind
()
# Rivets.TextBinding
# -----------------------
# A text node binding, defined internally to deal with text and element node
# differences while avoiding it being overwritten.
class
Rivets
.
TextBinding
extends
Rivets
.
Binding
# Initializes a text binding for the specified view and text node.
constructor
:
(
@
view
,
@
el
,
@
type
,
@
key
,
@
keypath
,
@
options
=
{})
->
@
formatters
=
@
options
.
formatters
||
[]
@
model
=
if
@
key
then
@
view
.
models
[
@
key
]
else
@
view
.
models
# A standard routine binder used for text node bindings.
binder
:
routine
:
(
node
,
value
)
->
node
.
data
=
value
?
''
# Wrap the call to `sync` in fat-arrow to avoid function context issues.
sync
:
=>
super
# Rivets.View
# -----------
...
...
Please
register
or
sign in
to post a comment