Class: AjaxHelper

Inherits:
Conveyors::Processor
  • Object
show all
Defined in:
lib/rad/processors/ajax_helper.rb

Overview

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>

Instance Method Summary collapse

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rad/processors/ajax_helper.rb', line 5

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