diff options
author | Thomas Fuchs <thomas@fesch.at> | 2005-10-01 05:43:53 +0000 |
---|---|---|
committer | Thomas Fuchs <thomas@fesch.at> | 2005-10-01 05:43:53 +0000 |
commit | e7afaf62bd9f6d3e7e7bf8b37d54d157ac6a3d6d (patch) | |
tree | 7e5d1717e1126dce29357cf8b351bbb24d1bca06 /actionpack/lib | |
parent | 1e08d11579f0080f086a6bfea1693826a0c09c95 (diff) | |
download | rails-e7afaf62bd9f6d3e7e7bf8b37d54d157ac6a3d6d.tar.gz rails-e7afaf62bd9f6d3e7e7bf8b37d54d157ac6a3d6d.tar.bz2 rails-e7afaf62bd9f6d3e7e7bf8b37d54d157ac6a3d6d.zip |
Added new scriptaculous options for auto_complete_field #2343 [m.stienstra@fngtps.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2431 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/java_script_macros_helper.rb | 23 |
1 files changed, 21 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 1cc814feaf..f4c99d422a 100644 --- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb @@ -85,8 +85,24 @@ module ActionView # <tt>:with</tt>:: A JavaScript expression specifying the # parameters for the XMLHttpRequest. This defaults # to 'fieldname=value'. - # <tt>:indicator</tt>:: Specifies the DOM ID of an elment which will be - # displayed while autocomplete is running. + # <tt>:indicator</tt>:: Specifies the DOM ID of an element which will be + # displayed while autocomplete is running. + # <tt>:tokens</tt>:: A string or an array of strings containing + # seperator tokens for tokenized incremental + # autocompletion. Example: <tt>:tokens => ','</tt> would + # allow multiple autocompletion entries, seperated + # by commas. + # <tt>:min_chars</tt>:: The minimum number of characters that should be + # in the input field before an Ajax call is made + # to the server. + # <tt>:on_hide</tt>:: A Javascript expression that is called when the + # autocompletion div is hidden. The expression + # should take two variables: element and update. + # Element is a DOM element for the field, update + # is a DOM element for the div from which the + # innerHTML is replaced. + # <tt>:on_show</tt>:: Like on_hide, only now the expression is called + # then the div is shown. def auto_complete_field(field_id, options = {}) function = "new Ajax.Autocompleter(" function << "'#{field_id}', " @@ -97,6 +113,9 @@ module ActionView js_options[:tokens] = array_or_string_for_javascript(options[:tokens]) if options[:tokens] js_options[:callback] = "function(element, value) { return #{options[:with]} }" if options[:with] js_options[:indicator] = "'#{options[:indicator]}'" if options[:indicator] + {:on_show => :onShow, :on_hide => :onHide, :min_chars => :min_chars}.each do |k,v| + js_options[v] = options[k] if options[k] + end function << (', ' + options_for_javascript(js_options) + ')') javascript_tag(function) |