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
2be61616
authored
2012-08-31 19:16:56 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Use jQuery to bind/unbind DOM events if loaded.
1 parent
46ef0f06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
src/rivets.coffee
src/rivets.coffee
View file @
2be6161
...
...
@@ -188,17 +188,25 @@ class Rivets.View
# Cross-browser event binding
bindEvent
=
(
el
,
event
,
fn
)
->
# Check to see if jQuery is loaded.
if
window
.
jQuery
?
el
=
jQuery
el
if
el
.
on
?
then
el
.
on
event
,
fn
else
el
.
bind
event
,
fn
# Check to see if addEventListener is available.
if
window
.
addEventListener
else
if
window
.
addEventListener
?
el
.
addEventListener
event
,
fn
,
false
else
# Assume we are in IE and use attachEvent.
# Assume we are in IE and use attachEvent.
event
=
"on"
+
event
el
.
attachEvent
event
,
fn
unbindEvent
=
(
el
,
event
,
fn
)
->
# Check to see if jQuery is loaded.
if
window
.
jQuery
?
el
=
jQuery
el
if
el
.
off
?
then
el
.
off
event
,
fn
else
el
.
unbind
event
,
fn
# Check to see if addEventListener is available.
if
window
.
removeEventListener
else
if
window
.
removeEventListener
el
.
removeEventListener
event
,
fn
,
false
else
# Assume we are in IE and use attachEvent.
...
...
Please
register
or
sign in
to post a comment