From 82aff27c043d3335277e18e3bd283e5b09b198fb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 14 Mar 2005 16:28:44 +0000 Subject: Remove the duplicated remote_function and make the real deal public git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@905 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_view/helpers/javascript_helper.rb | 34 +++++++--------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 619ce94341..814314a4be 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -57,9 +57,18 @@ module ActionView end def remote_function(options) + callbacks = build_callbacks(options) + function = options[:update] ? - "update_with_response('#{options[:update]}', '#{url_for(options[:url])}'#{', Form.serialize(this)' if options[:form]})" : - "xml_request('#{url_for(options[:url])}'#{', Form.serialize(this)' if options[:form]})" + "update_with_response('#{options[:update]}', " : + "xml_request(" + + function << "'#{url_for(options[:url])}'" + function << ', Form.serialize(this)' if options[:form] + function << ', null' if !options[:form] && callbacks + function << ", true" if callbacks || options[:type] != :sync + function << ", #{callbacks}" if callbacks + function << ')' function = "#{options[:before]}; #{function}" if options[:before] function = "#{function}; #{options[:after]}" if options[:after] @@ -267,27 +276,6 @@ module ActionView callbacks << "}" if callbacks callbacks end - - def remote_function(options) - callbacks = build_callbacks(options) - - function = options[:update] ? - "update_with_response('#{options[:update]}', " : - "xml_request(" - - function << "'#{url_for(options[:url])}'" - function << ', Form.serialize(this)' if options[:form] - function << ', null' if !options[:form] && callbacks - function << ", true" if callbacks || options[:type] != :sync - function << ", #{callbacks}" if callbacks - function << ')' - - function = "#{options[:before]}; #{function}" if options[:before] - function = "#{function}; #{options[:after]}" if options[:after] - function = "if (#{options[:condition]}) { #{function}; }" if options[:condition] - - return function - end end end end -- cgit v1.2.3