Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed that onclick would be overridden even when special features wer…

…ent used

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2158 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 079d8f402893dae8607bb7e272a6a038b840b4d2 1 parent 9053c4c
@dhh dhh authored
View
2  actionpack/lib/action_view/helpers/url_helper.rb
@@ -254,6 +254,8 @@ def convert_options_to_javascript!(html_options)
"#{post_javascript_function}return false;"
when popup
popup_javascript_function(popup) + 'return false;'
+ else
+ html_options["onclick"]
end
end
View
4 actionpack/test/template/url_helper_test.rb
@@ -47,6 +47,10 @@ def test_link_tag_with_straight_url
assert_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com")
end
+ def test_link_tag_with_custom_onclick
+ assert_equal "<a href=\"http://www.example.com\" onclick=\"alert('yay!')\">Hello</a>", link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')")
+ end
+
def test_link_tag_with_javascript_confirm
assert_equal(
"<a href=\"http://www.example.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>",
Please sign in to comment.
Something went wrong with that request. Please try again.