Module: Lipsiadmin::Controller::RespondsToParent

Defined in:
lib/controller/responds_to_parent.rb

Overview

Executes the response body as JavaScript in the context of the parent window.

Use this method of you are posting a form to a hidden IFRAME or if you would like to use IFRAME base RPC.

Instance Method Summary collapse

Instance Method Details

#redirect_parent_to(location) ⇒ Object

Redirect parent to a new url



20
21
22
23
24
25
26
# File 'lib/controller/responds_to_parent.rb', line 20

def redirect_parent_to(location)
  responds_to_parent do
    render :update do |page|
      page.load location
    end
  end
end

#render_to_parent(*options_for_render) ⇒ Object

Render an action to parent



9
10
11
12
13
14
15
16
17
18
# File 'lib/controller/responds_to_parent.rb', line 9

def render_to_parent(*options_for_render)
  responds_to_parent do
    # I don't use page.update for prevent dobule rendering 
    # and so we can save rendering time!
    source = render_to_string(*options_for_render)
    render :update do |page|
      page.call "Backend.app.update", source
    end
  end
end