Sha256: c88f2daf0cff09774fd178095d443f289fa6e56559ea30dbec6a9077cb9a3688
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
module RespondsToParent # Module containing the methods useful for child IFRAME to parent window communication module ActionController # 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. def responds_to_parent(&block) yield if performed? # Either pull out a redirect or the request body script = if location = erase_redirect_results "document.location.href = '#{self.class.helpers.escape_javascript location.to_s}'" else response.body || '' end # Clear out the previous render to prevent double render erase_results # We're returning HTML instead of JS or XML now response.headers['Content-Type'] = 'text/html; charset=UTF-8' @performed_render = false # Eval in parent scope and replace document location of this frame # so back button doesn't replay action on targeted forms # loc = document.location to be set after parent is updated for IE # with(window.parent) - pull in variables from parent window # setTimeout - scope the execution in the windows parent for safari # window.eval - legal eval for Opera render :text => "<html><body><script type='text/javascript' charset='utf-8'> var loc = document.location; with(window.parent) { setTimeout(function() { window.eval('#{self.class.helpers.escape_javascript script}'); window.loc && loc.replace('about:blank'); }, 1) } </script></body></html>" end end alias respond_to_parent responds_to_parent end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
siwilkins-responds_to_parent-1.0.20121128 | lib/responds_to_parent/action_controller.rb |