remote_function (ActionView::Helpers::PrototypeHelper)

    # File lib/action_view/helpers/prototype_helper.rb, line 288
          def remote_function(options)
            javascript_options = options_for_ajax(options)

            update = ''
            if options[:update] and options[:update].is_a?Hash
              update  = []
              update << "success:'#{options[:update][:success]}'" if options[:update][:success]
              update << "failure:'#{options[:update][:failure]}'" if options[:update][:failure]
              update  = '{' + update.join(',') + '}'
            elsif options[:update]
              update << "'#{options[:update]}'"
            end

            function = update.empty? ?
              "new Ajax.Request(" :
              "new Ajax.Updater(#{update}, "

            url_options = options[:url]
            url_options = url_options.merge(:escape => false) if url_options.is_a? Hash
            function << "'#{url_for(url_options)}'"
            function << ", #{javascript_options})"

            function = "#{options[:before]}; #{function}" if options[:before]
            function = "#{function}; #{options[:after]}"  if options[:after]
            function = "if (#{options[:condition]}) { #{function}; }" if options[:condition]
            function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if options[:confirm]

            return function
          end