From 10cf9ecafc4b1953cf8289e530cab7a0a751b9c4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 3 Jan 2006 04:11:51 +0000 Subject: 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 --- actionpack/lib/action_view/helpers/java_script_macros_helper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/helpers/java_script_macros_helper.rb') 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 field_id_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 activate method on that object). # # Required +options+ are: # :url:: 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])}'" -- cgit v1.2.3