adding an onclick option to link_to method

Hello,

I'm trying to use the rail link_to to open a popup window and then print the popup window at the same time. Is there a way to add another "onclick" option to tell the popup to print? I know how to do this in javascript but not sure how to use the rails help to do it. I also am aware that the link_to_function method is used to call a javascript function. Here's the code I have to open the popup:

<%= link_to icon('icon_printer', :alt => 'Print') + 'Print Cable', {:controller => 'print_popup',                            :action => 'display_popup',                            :doc => @document,                            :header => 'My Doc'},                            :title => 'My Title',                            :popup => ['display_popup_to', 'width=650,height=600,scrollbars=yes, menubar=1']%>

tblack06 wrote:

Hello,

I'm trying to use the rail link_to to open a popup window and then print the popup window at the same time. Is there a way to add another "onclick" option to tell the popup to print? I know how to do this in javascript but not sure how to use the rails help to do it. I also am aware that the link_to_function method is used to call a javascript function. Here's the code I have to open the popup:

<%= link_to icon('icon_printer', :alt => 'Print') + 'Print Cable', {:controller => 'print_popup',                            :action => 'display_popup',                            :doc => @document,                            :header => 'My Doc'},                            :title => 'My Title',                            :popup => ['display_popup_to', 'width=650,height=600,scrollbars=yes, menubar=1']%>

Here is how I did mine:

<%=link_to_function "Print","window.print();" %>

But I had to fist generate the popup window using another link:

<%=link_to "Print Voids List",{:action=>"print_voids"},:popup=>['new_window','height=300,width=600','scrollbars=yes']%>

Maybe?: <%= link_to_function icon('icon_printer', :alt => 'Print') + 'Print Cable', :action = 'display_popup', :popup => ['display_popup_to', 'width=650,height=600,scrollbars=yes, menubar=1'], "window.print();" %>

This is purely a guess though, I haven't tried it out. But the "window.print()" part does work on my app, I think you just have to find a way to combine the two. Good luck,

-S