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
2a04d617
authored
2012-07-30 18:06:03 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #40 from paulj/support-number-inputs
Support inputs of type number
2 parents
962107e9
751de7b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
spec/rivets/binding.js
src/rivets.coffee
spec/rivets/binding.js
View file @
2a04d61
...
...
@@ -99,6 +99,24 @@ describe('Rivets.Binding', function() {
});
});
});
describe
(
'publish()'
,
function
()
{
it
(
"should publish the value of a number input"
,
function
()
{
numberInput
=
document
.
createElement
(
'input'
);
numberInput
.
setAttribute
(
'type'
,
'number'
);
numberInput
.
setAttribute
(
'data-value'
,
'obj.num'
);
view
=
rivets
.
bind
(
numberInput
,
{
obj
:
{
num
:
42
}});
binding
=
view
.
bindings
[
0
];
model
=
binding
.
model
;
numberInput
.
value
=
42
;
spyOn
(
rivets
.
config
.
adapter
,
'publish'
);
binding
.
publish
({
target
:
numberInput
});
expect
(
rivets
.
config
.
adapter
.
publish
).
toHaveBeenCalledWith
(
model
,
'num'
,
'42'
);
});
});
describe
(
'formattedValue()'
,
function
()
{
it
(
'applies the current formatters on the supplied value'
,
function
()
{
...
...
src/rivets.coffee
View file @
2a04d61
...
...
@@ -148,7 +148,7 @@ unbindEvent = (el, event, fn) ->
# Returns the current input value for the specified element.
getInputValue
=
(
el
)
->
switch
el
.
type
when
'text'
,
'textarea'
,
'password'
,
'select-one'
,
'radio'
then
el
.
value
when
'text'
,
'textarea'
,
'password'
,
'select-one'
,
'radio'
,
'number'
then
el
.
value
when
'checkbox'
then
el
.
checked
# Returns an event binding routine for the specified event.
...
...
Please
register
or
sign in
to post a comment