diff options
author | Thomas Fuchs <thomas@fesch.at> | 2005-09-28 08:20:47 +0000 |
---|---|---|
committer | Thomas Fuchs <thomas@fesch.at> | 2005-09-28 08:20:47 +0000 |
commit | 516dc2c0f16cf187f981b5e8648a7f7f1b31d190 (patch) | |
tree | d645e19a02ab5eb371302fe4742b7fd7e0a1a1e2 /actionpack/lib/action_view/helpers/java_script_macros_helper.rb | |
parent | dd21e9ae39a2dc4b7eb607ff2c200c864fa19b28 (diff) | |
download | rails-516dc2c0f16cf187f981b5e8648a7f7f1b31d190.tar.gz rails-516dc2c0f16cf187f981b5e8648a7f7f1b31d190.tar.bz2 rails-516dc2c0f16cf187f981b5e8648a7f7f1b31d190.zip |
Update script.aculo.us to 1.5_rc2, and Prototype to 1.4.0_pre7
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2386 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 | 38 |
1 files changed, 34 insertions, 4 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 8c67edd645..1cc814feaf 100644 --- a/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +++ b/actionpack/lib/action_view/helpers/java_script_macros_helper.rb @@ -74,9 +74,8 @@ module ActionView # input field. # # Required +options+ are: - # <tt>:url</tt>:: Specifies the DOM ID of the element whose - # innerHTML should be updated with the autocomplete - # entries returned by XMLHttpRequest. + # <tt>:url</tt>:: URL to call for autocompletion results + # in url_for format. # # Addtional +options+ are: # <tt>:update</tt>:: Specifies the DOM ID of the element whose @@ -130,10 +129,41 @@ module ActionView # See the RDoc on ActionController::AutoComplete to learn more about this. def text_field_with_auto_complete(object, method, tag_options = {}, completion_options = {}) (completion_options[:skip_style] ? "" : auto_complete_stylesheet) + - text_field(object, method, { :autocomplete => "off" }.merge!(tag_options)) + + text_field(object, method, tag_options) + content_tag("div", "", :id => "#{object}_#{method}_auto_complete", :class => "auto_complete") + auto_complete_field("#{object}_#{method}", { :url => { :action => "auto_complete_for_#{object}_#{method}" } }.update(completion_options)) end + + private + def auto_complete_stylesheet + content_tag("style", <<-EOT + div.auto_complete { + width: 350px; + background: #fff; + } + div.auto_complete ul { + border:1px solid #888; + margin:0; + padding:0; + width:100%; + list-style-type:none; + } + div.auto_complete ul li { + margin:0; + padding:3px; + } + div.auto_complete ul li.selected { + background-color: #ffb; + } + div.auto_complete ul strong.highlight { + color: #800; + margin:0; + padding:0; + } + EOT + ) + end + end end end |