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
11 years ago
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
# -----------
...
...
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to post a comment