aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/javascript_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-01-03 04:11:51 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-01-03 04:11:51 +0000
commit10cf9ecafc4b1953cf8289e530cab7a0a751b9c4 (patch)
tree53c4ad06e6b897d3bebd368e1701d0b264a816e9 /actionpack/lib/action_view/helpers/javascript_helper.rb
parent987d9dbf31b6bb4fe1547bca17af920aa3d72ac5 (diff)
downloadrails-10cf9ecafc4b1953cf8289e530cab7a0a751b9c4.tar.gz
rails-10cf9ecafc4b1953cf8289e530cab7a0a751b9c4.tar.bz2
rails-10cf9ecafc4b1953cf8289e530cab7a0a751b9c4.zip
Added assignment of the Autocompleter object created by JavaScriptMacroHelper#auto_complete_field to a local javascript variables [DHH] Added :on option for PrototypeHelper#observe_field that allows you to specify a different callback hook to have the observer trigger on [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3378 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/javascript_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index d61167b264..15609d5290 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -57,6 +57,20 @@ module ActionView
})
)
end
+
+ # Returns a link that'll trigger a JavaScript +function+ using the
+ # onclick handler.
+ #
+ # Examples:
+ # button_to_function "Greeting", "alert('Hello world!')"
+ # button_to_function "Delete", "if confirm('Really?'){ do_delete(); }")
+ def button_to_function(name, function, html_options = {})
+ html_options.symbolize_keys!
+ tag(:input, html_options.merge({
+ :type => "button", :value => name,
+ :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
+ }))
+ end
# Returns a link that'll trigger a JavaScript +function+ using the
# onclick handler.