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
b2eb4729
authored
2012-07-24 16:16:01 +1000
by
Paul Jones
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Support passing multiple elements to Rivets.View
1 parent
3e37aba8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
spec/rivets/functional.js
src/rivets.coffee
spec/rivets/functional.js
View file @
b2eb472
...
...
@@ -90,6 +90,16 @@ describe('Functional', function() {
expect
(
input
.
value
).
toBe
(
data
.
get
(
'foo'
));
});
});
describe
(
'Multiple'
,
function
()
{
it
(
'should bind a list of multiple elements'
,
function
()
{
el
.
setAttribute
(
'data-html'
,
'data.foo'
);
input
.
setAttribute
(
'data-value'
,
'data.foo'
);
rivets
.
bind
([
el
,
input
],
bindData
);
expect
(
el
).
toHaveTheTextContent
(
data
.
get
(
'foo'
));
expect
(
input
.
value
).
toBe
(
data
.
get
(
'foo'
));
});
});
});
describe
(
'Updates'
,
function
()
{
...
...
src/rivets.coffee
View file @
b2eb472
...
...
@@ -69,8 +69,8 @@ class Rivets.Binding
class
Rivets
.
View
# The parent DOM element and the model objects for binding are passed into the
# constructor.
constructor
:
(
@
el
,
@
models
)
->
@
el
=
@
el
.
get
(
0
)
if
@
el
.
jquery
constructor
:
(
@
el
s
,
@
models
)
->
@
el
s
=
[
@
els
]
unless
(
@
els
.
jquery
||
@
els
instanceof
Array
)
@
build
()
# Regular expression used to match binding attributes.
...
...
@@ -102,8 +102,9 @@ class Rivets.View
@
bindings
.
push
new
Rivets
.
Binding
node
,
type
,
bindType
,
model
,
keypath
,
pipes
parseNode
@
el
parseNode
node
for
node
in
@
el
.
getElementsByTagName
'*'
for
el
in
@
els
parseNode
el
parseNode
node
for
node
in
el
.
getElementsByTagName
'*'
# Binds all of the current bindings for this view.
bind
:
=>
...
...
Please
register
or
sign in
to post a comment