method

options_for_ajax

Importance_0
v2.1.0 - Show latest stable - 0 notes - Class: ActionView::Helpers::PrototypeHelper
options_for_ajax(options) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actionpack/lib/action_view/helpers/prototype_helper.rb, line 1037
      def options_for_ajax(options)
        js_options = build_callbacks(options)
      
        js_options['asynchronous'] = options[:type] != :synchronous
        js_options['method']       = method_option_to_s(options[:method]) if options[:method]
        js_options['insertion']    = "Insertion.#{options[:position].to_s.camelize}" if options[:position]
        js_options['evalScripts']  = options[:script].nil? || options[:script]

        if options[:form]
          js_options['parameters'] = 'Form.serialize(this)'
        elsif options[:submit]
          js_options['parameters'] = "Form.serialize('#{options[:submit]}')"
        elsif options[:with]
          js_options['parameters'] = options[:with]
        end
        
        if protect_against_forgery? && !options[:form]
          if js_options['parameters']
            js_options['parameters'] << " + '&"
          else
            js_options['parameters'] = "'"
          end
          js_options['parameters'] << "#{request_forgery_protection_token}=' + encodeURIComponent('#{escape_javascript form_authenticity_token}')"
        end
      
        options_for_javascript(js_options)
      end
Register or log in to add new notes.