Sha256: a40e7041973a74a0858acc149c52ea8340d6c176cad085ce9aa6b40062af555a

Contents?: true

Size: 615 Bytes

Versions: 6

Compression:

Stored size: 615 Bytes

Contents

# Sets format for :js as :html and wraps body into <textarea>
# Forms with files can be submitted by ajax only via iframe, and it requires 
# the response have 'html' encoding and be wrapped into <textarea>
class AjaxHelper < Conveyors::Processor      
  def call
    response = workspace.response.must_be.defined
    request = workspace.request.must_be.defined
    
    next_processor.call
    
    if workspace.params? and workspace.params.format == 'js' and !request.xhr?
      response.content_type = Mime['html']
      workspace.content = "<textarea>#{workspace.content}</textarea>"
    end          
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rad_ext-0.0.6 lib/rad/processors/ajax_helper.rb
rad_ext-0.0.5 lib/rad/processors/ajax_helper.rb
rad_ext-0.0.4 lib/rad/processors/ajax_helper.rb
rad_ext-0.0.3 lib/rad/processors/ajax_helper.rb
rad_ext-0.0.2 lib/rad/processors/ajax_helper.rb
rad_ext-0.0.1 lib/rad/processors/ajax_helper.rb