Sha256: f8caf3695c0232873e576174cf7bf246d138658351837318e54e3a96a0a1c8cb

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

module ActionView
  module Helpers
    module PrototypeHelper

      def update_element_function(element_id, options = {}, &block)
        content = escape_javascript(options[:content] || '')
        content = escape_javascript(capture(&block)) if block
        
        javascript_function = case (options[:action] || :update)
          when :update
            if options[:position]
              "new Insertion.#{options[:position].to_s.camelize}('#{element_id}','#{content}')"
            else
              "$('#{element_id}').innerHTML = '#{content}'"
            end
          
          when :empty
            "$('#{element_id}').innerHTML = ''"
          
          when :remove
            "Element.remove('#{element_id}')"
          
          else
            raise ArgumentError, "Invalid action, choose one of :update, :remove, :empty"
        end
        
        javascript_function << ";\n"
        options[:binding] ? concat(javascript_function, options[:binding]) : javascript_function
      end
      deprecate :update_element_function => "use RJS instead"
      
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
actionpack-1.13.0 lib/action_view/helpers/deprecated_helper.rb
actionpack-1.13.1 lib/action_view/helpers/deprecated_helper.rb
actionpack-1.13.2 lib/action_view/helpers/deprecated_helper.rb
actionpack-1.13.3 lib/action_view/helpers/deprecated_helper.rb
radiant-0.6.0 vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb
radiant-0.6.1 vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb
radiant-0.6.2 vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb
radiant-0.6.3 vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb
rq-3.4.0 rails/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb
rq-3.3.0 rails/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb