diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-12-31 03:50:08 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-12-31 03:50:08 +0000 |
commit | 341d34cd50ab1d807a9d515058d1da8fe75deb01 (patch) | |
tree | 157be187ddfeb78f3bef7bec0ef161b98ae35d5a /actionpack/lib | |
parent | 00541f263b0aac16cdfcef68b4af5b1877f4dd02 (diff) | |
download | rails-341d34cd50ab1d807a9d515058d1da8fe75deb01.tar.gz rails-341d34cd50ab1d807a9d515058d1da8fe75deb01.tar.bz2 rails-341d34cd50ab1d807a9d515058d1da8fe75deb01.zip |
Added that JavaScriptHelper#link_to_function will honor existing :onclick definitions when adding the function call [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3364 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 033aff5044..7dccecda13 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -48,9 +48,13 @@ module ActionView # link_to_function "Greeting", "alert('Hello world!')" # link_to_function(image_tag("delete"), "if confirm('Really?'){ do_delete(); }") def link_to_function(name, function, html_options = {}) + html_options.symbolize_keys! content_tag( "a", name, - {:href => "#", :onclick => "#{function}; return false;"}.merge(html_options.symbolize_keys) + html_options.merge({ + :href => html_options[:href] || "#", + :onclick => "#{function};#{html_options[:onclick] ? " #{html_options[:onclick]};" : ""} return false;" + }) ) end |