diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-03 04:11:51 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-03 04:11:51 +0000 |
commit | 10cf9ecafc4b1953cf8289e530cab7a0a751b9c4 (patch) | |
tree | 53c4ad06e6b897d3bebd368e1701d0b264a816e9 /actionpack/lib/action_view/helpers/java_script_macros_helper.rb | |
parent | 987d9dbf31b6bb4fe1547bca17af920aa3d72ac5 (diff) | |
download | rails-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/java_script_macros_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/java_script_macros_helper.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb index 47ae26e54e..f8b45a9e42 100644 --- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb @@ -72,8 +72,12 @@ module ActionView # or nothing if no entries should be displayed for autocompletion. # # You'll probably want to turn the browser's built-in autocompletion off, - # su be sure to include a autocomplete="off" attribute with your text + # so be sure to include a autocomplete="off" attribute with your text # input field. + # + # The autocompleter object is assigned to a Javascript variable named <tt>field_id</tt>_auto_completer. + # This object is useful if you for example want to trigger the auto-complete suggestions through + # other means than user input (for that specific case, call the <tt>activate</tt> method on that object). # # Required +options+ are: # <tt>:url</tt>:: URL to call for autocompletion results @@ -109,7 +113,7 @@ module ActionView # insertion should be extracted. If this is not specified, # the entire element is used. def auto_complete_field(field_id, options = {}) - function = "new Ajax.Autocompleter(" + function = "var #{field_id}_auto_completer = new Ajax.Autocompleter(" function << "'#{field_id}', " function << "'" + (options[:update] || "#{field_id}_auto_complete") + "', " function << "'#{url_for(options[:url])}'" |