Turns out that link_to handles popups,
You’d know this if you looked in the rdoc, but if you’re new to rails, you might not be down with that yet.
You can write code like:
- <%= link_to "pop me up", { :action => "show" }, :popup => [‘new_window‘,height=300,width=600‘] %>
I’m happier putting a javascript function in myself, and calling that, using onclick=>”popup(‘new_window’, 300, 600);” where function is something like:.
- function popup(window_name, url, p_width, p_height) {
- var new_window = window.open( url, window_name, "status = 1, height = " + p_height +", width = " + p_width );
- new_window.focus();
- }
I do this because then I can actually bring the window to the front (or specify more args, etc), I guess it could also be a matter of taste.
In fact, these days, I’m happier not using helpers like link_to for trivial stuff anyhow.

RSS Feed