Forum: Ruby on Rails A quick question on popup windows

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eric S. (Guest)
on 2006-02-11 08:40
(Received via mailing list)
How the hell do you close em off after the action is completed?
Ta,
Eric
Eric S. (Guest)
on 2006-02-12 04:58
(Received via mailing list)
I'm curious as to how to close a browser window opened as

<%= link_to(image_tag("new_organisation.png", :alt => 'New', :border =>
1), { :controller => 'to_dos', :action => 'to_do_pop_up'}, :popup =>
['new_window', 'height=500,width=800'])

which performs exactly as desired within the controller on submit

And my question is =>

after the record is processed...

flash[:notice] = 'Note was successfully created.'
if !(params['id'] == nil)
    redirect_to :action => 'job_dashboard', :id => @job
else
    render WHAT???    <--- THIS LINE NEEDS TO CLOSE THE POP_UP
end
Jim (Guest)
on 2006-02-12 05:07
Eric S. wrote:

>     render WHAT???    <--- THIS LINE NEEDS TO CLOSE THE POP_UP
> end

render :text => "<script>window.close()</script>"
Eric S. (Guest)
on 2006-02-12 07:07
(Received via mailing list)
Thanks Jim - that was exactly what I needed. I figured there had to be
some render method to do that - I'd never have figured render :text tho.
Thanks again.
Cheers,
Eric.
Jim (Guest)
on 2006-02-12 18:33
Eric S. wrote:
> Thanks Jim - that was exactly what I needed. I figured there had to be
> some render method to do that - I'd never have figured render :text tho.
> Thanks again.
> Cheers,
> Eric.

Well, the     render :text => "string"      just renders the plain text,
or sting - which happens to be  a bit of JavaScript. If a user has
JavaScript disabled in the browser, it won't work.
Eric S. (Guest)
on 2006-02-12 23:22
(Received via mailing list)
Well, in my current case, I have control over whether JS is enabled - so
that's OK. But out of interest how would we close the window otherwise?
Ben M. (Guest)
on 2006-02-12 23:50
(Received via mailing list)
Can't... The only way to control a user's browser is with javascript.
Welcome to the
wonderful world of web programming!

b
Eric S. (Guest)
on 2006-02-13 03:05
(Received via mailing list)
Bugger!
Thanks Guys
This topic is locked and can not be replied to.