internetchris
2009-Sep-17 17:13 UTC
(rails question) placing link_to inside javascript tags? Options
Hey everyone, I''m wondering if anyone has tried to use the link_to function inside <script> tags in a view? I''m using facebox to create a lightbox effect on a link. I want to place this inside a javascript function so I can use it via a button in a js form. Here''s what I would like to do, but I''m not sure if it''s possible. Has anyone done this before? I''m thinking I might have to dig into facebox to see how to pass what I want using pure javascript. I''m not a javascript programmer, so a rails approach would be easier for me. Here''s what I would like to do... <script type="text/javascript"> function test(com,grid) { if (com==''Delete'') { confirm(''Delete '' + $(''.trSelected'',grid).length + '' items?'') } else if (com==''Add'') { <%=facebox_link_to "+New Reading", :url => ''readings/ new'', :method=>''get''%>; } else { alert(''Test'') } } </script> Any help is appreciated. Chris