aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/prototype_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/prototype_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/prototype_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index a9a68f474b..d35334a98c 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -337,11 +337,16 @@ module ActionView
# parameters for the XMLHttpRequest. This defaults
# to 'value', which in the evaluated context
# refers to the new field value.
+ # <tt>:on</tt>:: Specifies which event handler to observe. By default,
+ # it's set to "changed" for text fields and areas and
+ # "click" for radio buttons and checkboxes. With this,
+ # you can specify it instead to be "blur" or "focus" or
+ # any other event.
#
# Additionally, you may specify any of the options documented in
# link_to_remote.
def observe_field(field_id, options = {})
- if options[:frequency] and options[:frequency] > 0
+ if options[:frequency] && options[:frequency] > 0
build_observer('Form.Element.Observer', field_id, options)
else
build_observer('Form.Element.EventObserver', field_id, options)
@@ -567,7 +572,9 @@ module ActionView
javascript = "new #{klass}('#{name}', "
javascript << "#{options[:frequency]}, " if options[:frequency]
javascript << "function(element, value) {"
- javascript << "#{callback}})"
+ javascript << "#{callback}}"
+ javascript << ", '#{options[:on]}'" if options[:on]
+ javascript << ")"
javascript_tag(javascript)
end