Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add preventDefault() on click event #14316

Merged
merged 1 commit into from

2 participants

@the4dpatrick

If source was copied directly, then page is refreshed. Changed to prevent default event.

@arthurnn arthurnn merged commit 5ecb52c into rails:master
@arthurnn
Collaborator

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2014
  1. @the4dpatrick
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 guides/source/working_with_javascript_in_rails.md
View
4 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)
Something went wrong with that request. Please try again.