diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-02 19:41:04 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-09-02 19:41:04 +0000 |
commit | 6e08dab186f3dd03e4ad598d3a55dfedce7c46bc (patch) | |
tree | afe0198d4243eaa9e6b6a2074e4c186dc019edea /actionpack/lib | |
parent | 3859d6da6e3c577c00a6a3610f8ba1b1911f1029 (diff) | |
download | rails-6e08dab186f3dd03e4ad598d3a55dfedce7c46bc.tar.gz rails-6e08dab186f3dd03e4ad598d3a55dfedce7c46bc.tar.bz2 rails-6e08dab186f3dd03e4ad598d3a55dfedce7c46bc.zip |
Docs for js linkers (closes #5948)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4904 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 86829c2738..8777b51b9a 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -44,7 +44,7 @@ module ActionView include PrototypeHelper - # Returns a link that'll trigger a JavaScript +function+ using the + # Returns a link that will trigger a JavaScript +function+ using the # onclick handler and return false after the fact. # # The +function+ argument can be omitted in favor of an +update_page+ @@ -53,11 +53,32 @@ module ActionView # # Examples: # link_to_function "Greeting", "alert('Hello world!')" + # Produces: + # <a onclick="alert('Hello world!'); return false;" href="#">Greeting</a> + # # link_to_function(image_tag("delete"), "if (confirm('Really?')) do_delete()") + # Produces: + # <a onclick="if (confirm('Really?')) do_delete(); return false;" href="#"> + # <img src="/images/delete.png?" alt="Delete"/> + # </a> + # # link_to_function("Show me more", nil, :id => "more_link") do |page| # page[:details].visual_effect :toggle_blind # page[:more_link].replace_html "Show me less" # end + # Produces: + # <a href="#" id="more_link" onclick="try { + # $("details").visualEffect("toggle_blind"); + # $("more_link").update("Show me less"); + # } + # catch (e) { + # alert('RJS error:\n\n' + e.toString()); + # alert('$(\"details\").visualEffect(\"toggle_blind\"); + # \n$(\"more_link\").update(\"Show me less\");'); + # throw e + # }; + # return false;">Show me more</a> + # def link_to_function(name, function = '', html_options = {}, &block) html_options.symbolize_keys! function = update_page(&block) if block_given? |