From 91156b6f0ced65b5681874e2cf2a95e045d708e9 Mon Sep 17 00:00:00 2001 From: Patrick Perey Date: Fri, 7 Mar 2014 10:46:27 -0800 Subject: Add preventDefault() on click event --- guides/source/working_with_javascript_in_rails.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'guides') 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) -- cgit v1.2.3