diff options
author | Thomas Fuchs <thomas@fesch.at> | 2006-09-07 09:19:35 +0000 |
---|---|---|
committer | Thomas Fuchs <thomas@fesch.at> | 2006-09-07 09:19:35 +0000 |
commit | 8734da9bca3db5934f0d072feeca0b1724d082a7 (patch) | |
tree | 87e74e5a54561e3fd0aa6b46a04baa98ff0d5ec6 /actionpack/lib | |
parent | 00685ad8fdc9f15d935aebe52597037f3ca93be8 (diff) | |
download | rails-8734da9bca3db5934f0d072feeca0b1724d082a7.tar.gz rails-8734da9bca3db5934f0d072feeca0b1724d082a7.tar.bz2 rails-8734da9bca3db5934f0d072feeca0b1724d082a7.zip |
Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, fixes #6068 [petermichaux@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5057 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/prototype_helper.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 1f547d4809..b6f811aee1 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -556,22 +556,22 @@ module ActionView # Removes the DOM elements with the given +ids+ from the page. def remove(*ids) - record "#{javascript_object_for(ids)}.each(Element.remove)" + loop_on_multiple_args 'Element.remove', ids end # Shows hidden DOM elements with the given +ids+. def show(*ids) - call 'Element.show', *ids + loop_on_multiple_args 'Element.show', ids end # Hides the visible DOM elements with the given +ids+. def hide(*ids) - call 'Element.hide', *ids + loop_on_multiple_args 'Element.hide', ids end # Toggles the visibility of the DOM elements with the given +ids+. def toggle(*ids) - call 'Element.toggle', *ids + loop_on_multiple_args 'Element.toggle', ids end # Displays an alert dialog with the given +message+. @@ -684,6 +684,14 @@ module ActionView end protected + def loop_on_multiple_args(method, ids) + record (if ids.size>1 + "#{javascript_object_for(ids)}.each(#{method})" + else + "#{method}(#{ids.first.to_json})" + end) + end + def options_for_ajax(options) js_options = build_callbacks(options) |