Sha256: 0306d316d5159373c4ffbd3bf4097190e59571edd24c53c3bee6efc3e822cf75

Contents?: true

Size: 636 Bytes

Versions: 12

Compression:

Stored size: 636 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 Rad::Web::Processors::AjaxHelper < Rad::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

12 entries across 12 versions & 1 rubygems

Version Path
rad_core-0.2.6 lib/rad/web/_ajax_helper.rb
rad_core-0.2.5 lib/rad/web/_ajax_helper.rb
rad_core-0.2.4 lib/rad/web/_ajax_helper.rb
rad_core-0.2.3 lib/rad/web/_ajax_helper.rb
rad_core-0.2.2 lib/rad/web/_ajax_helper.rb
rad_core-0.2.1 lib/rad/web/_ajax_helper.rb
rad_core-0.2.0 lib/rad/web/_ajax_helper.rb
rad_core-0.0.30 lib/rad/web/_ajax_helper.rb
rad_core-0.0.29 lib/rad/web/_ajax_helper.rb
rad_core-0.0.28 lib/rad/web/_ajax_helper.rb
rad_core-0.0.27 lib/rad/web/_ajax_helper.rb
rad_core-0.0.26 lib/rad/web/_ajax_helper.rb