aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorPatrick Perey <the4dpatrick@yahoo.com>2014-03-07 10:46:27 -0800
committerPatrick Perey <the4dpatrick@yahoo.com>2014-03-07 10:46:27 -0800
commit91156b6f0ced65b5681874e2cf2a95e045d708e9 (patch)
tree61cc408f2266188d94a91685c0bbca164b6a4353 /guides
parent70ff31d69f017d1bc674b913865d5a008de0c8a6 (diff)
downloadrails-91156b6f0ced65b5681874e2cf2a95e045d708e9.tar.gz
rails-91156b6f0ced65b5681874e2cf2a95e045d708e9.tar.bz2
rails-91156b6f0ced65b5681874e2cf2a95e045d708e9.zip
Add preventDefault() on click event
Diffstat (limited to 'guides')
-rw-r--r--guides/source/working_with_javascript_in_rails.md4
1 files changed, 3 insertions, 1 deletions
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index a8695ec034..aba3c9ed61 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -111,7 +111,9 @@ paintIt = (element, backgroundColor, textColor) ->
element.style.color = textColor
$ ->
- $("a[data-background-color]").click ->
+ $("a[data-background-color]").click (e) ->
+ e.preventDefault()
+
backgroundColor = $(this).data("background-color")
textColor = $(this).data("text-color")
paintIt(this, backgroundColor, textColor)