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
019fa5c4
authored
2013-03-19 20:05:06 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add support for passing in the current model when processing data-on.
1 parent
5cd20248
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
lib/rivets.js
lib/rivets.min.js
src/rivets.coffee
lib/rivets.js
View file @
019fa5c
...
...
@@ -18,13 +18,14 @@
Rivets
.
Binding
=
(
function
()
{
function
Binding
(
el
,
type
,
model
,
keypath
,
options
)
{
function
Binding
(
el
,
type
,
model
,
keypath
,
options
,
bindContext
)
{
var
identifier
,
regexp
,
value
,
_ref
;
this
.
el
=
el
;
this
.
type
=
type
;
this
.
model
=
model
;
this
.
keypath
=
keypath
;
this
.
options
=
options
!=
null
?
options
:
{};
this
.
bindContext
=
bindContext
;
this
.
unbind
=
__bind
(
this
.
unbind
,
this
);
this
.
bind
=
__bind
(
this
.
bind
,
this
);
...
...
@@ -278,7 +279,7 @@
if
(
dependencies
=
context
.
shift
())
{
options
.
dependencies
=
dependencies
.
split
(
/
\s
+/
);
}
binding
=
new
Rivets
.
Binding
(
node
,
type
,
model
,
keypath
,
options
);
binding
=
new
Rivets
.
Binding
(
node
,
type
,
model
,
keypath
,
options
,
_this
.
models
);
binding
.
view
=
_this
;
_this
.
bindings
.
push
(
binding
);
}
...
...
@@ -366,10 +367,10 @@
})();
bindEvent
=
function
(
el
,
event
,
handler
,
context
)
{
bindEvent
=
function
(
el
,
event
,
handler
,
context
,
bindContext
)
{
var
fn
;
fn
=
function
(
e
)
{
return
handler
.
call
(
context
,
e
);
return
handler
.
call
(
context
,
e
,
bindContext
);
};
if
(
window
.
jQuery
!=
null
)
{
el
=
jQuery
(
el
);
...
...
@@ -508,7 +509,7 @@
if
(
this
.
currentListener
)
{
unbindEvent
(
el
,
this
.
args
[
0
],
this
.
currentListener
);
}
return
this
.
currentListener
=
bindEvent
(
el
,
this
.
args
[
0
],
value
,
this
.
model
);
return
this
.
currentListener
=
bindEvent
(
el
,
this
.
args
[
0
],
value
,
this
.
model
,
this
.
bindContext
);
}
},
"each-*"
:
{
...
...
lib/rivets.min.js
View file @
019fa5c
This diff is collapsed.
Click to expand it.
src/rivets.coffee
View file @
019fa5c
...
...
@@ -14,7 +14,7 @@ class Rivets.Binding
# All information about the binding is passed into the constructor; the DOM
# element, the type of binding, the model object and the keypath at which
# to listen for changes.
constructor
:
(
@
el
,
@
type
,
@
model
,
@
keypath
,
@
options
=
{})
->
constructor
:
(
@
el
,
@
type
,
@
model
,
@
keypath
,
@
options
=
{}
,
@
bindContext
)
->
unless
@
binder
=
Rivets
.
binders
[
type
]
for
identifier
,
value
of
Rivets
.
binders
if
identifier
isnt
'*'
and
identifier
.
indexOf
(
'*'
)
isnt
-
1
...
...
@@ -184,7 +184,7 @@ class Rivets.View
if
dependencies
=
context
.
shift
()
options
.
dependencies
=
dependencies
.
split
/\s+/
binding
=
new
Rivets
.
Binding
node
,
type
,
model
,
keypath
,
options
binding
=
new
Rivets
.
Binding
node
,
type
,
model
,
keypath
,
options
,
@
models
binding
.
view
=
@
@
bindings
.
push
binding
...
...
@@ -220,8 +220,8 @@ class Rivets.View
binding
.
publish
()
for
binding
in
@
select
(
b
)
->
b
.
binder
.
publishes
# Cross-browser event binding.
bindEvent
=
(
el
,
event
,
handler
,
context
)
->
fn
=
(
e
)
->
handler
.
call
context
,
e
bindEvent
=
(
el
,
event
,
handler
,
context
,
bindContext
)
->
fn
=
(
e
)
->
handler
.
call
context
,
e
,
bindContext
# Check to see if jQuery is loaded.
if
window
.
jQuery
?
...
...
@@ -321,7 +321,7 @@ Rivets.binders =
function
:
true
routine
:
(
el
,
value
)
->
unbindEvent
el
,
@
args
[
0
],
@
currentListener
if
@
currentListener
@
currentListener
=
bindEvent
el
,
@
args
[
0
],
value
,
@
model
@
currentListener
=
bindEvent
el
,
@
args
[
0
],
value
,
@
model
,
@
bindContext
"each-*"
:
block
:
true
...
...
Please
register
or
sign in
to post a comment