r.g.
2007-Aug-15 06:28 UTC
how to make a link containing ''link_to_remote'' call and executable JS
Hey there, I need to create a link that does both of the following in sequence: 1) updates an element using RJS, e.g. <%= link_to_remote h(video.title), :url => { :action => :do_stuff, :id => video ... (with the ''replace_html'' call included in "do_stuff.rjs") 2) sends some javascript to a flash video player using a link generated from object data, e.g. <a href="javascript:;" onclick="loadFile({file:''<%= h video.url %>'',title:''<%= h video.title %>'' ... I''ve gotten part 1 to work just fine. And of course, I can get part 2 to work if I''m not trying to do part 1. So my question is: is there a way to perform both actions with the same link, so that a single click updates an element Ajax-style AND loads the video into my player? I suspect this is possible using the "page << " syntax in RJS. But I don''t see how I could write out a list of links using a partial on a collection of objects. I don''t have the option of replacing any HTML either, since I need the javascript actually executed, on the same click that also updates another element. Any ideas? Thanks so much for any help you can give me. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld
2007-Aug-15 11:34 UTC
Re: how to make a link containing ''link_to_remote'' call and
> Any ideas? Thanks so much for any help you can give me.definitely not the most elegant solution, but quite a quick one - just copy the html that the link_to_remote puts out, and put the onclick function you need straight in there: function LOAD_FILE(var, var2, var3..) { //stuff } <a href="#" onclick="new Ajax.Request(''/main/sh'', {asynchronous:true, evalScripts:true}); LOAD_FILE(vars...); return false;">lsls</a> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld
2007-Aug-15 11:37 UTC
Re: how to make a link containing ''link_to_remote'' call and
> <a href="#" onclick="new Ajax.Request(''/main/sh'', {asynchronous:true, > evalScripts:true}); LOAD_FILE(vars...); return false;">lsls</a>sorry bout that, i meant (in the onclick section) : new Ajax.Updater(''dom_to_update'', ''/action/on/server/for/ajax'', {asynchronous:true, evalScripts:true}); LOAD_FILE(<%= rubyvars %>); return false; -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! I did what you suggested, although it seemed to work only if the call to my video player went first. But the desired result has been achieved. Thanks again. On Aug 15, 4:37 am, Shai Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > <a href="#" onclick="new Ajax.Request(''/main/sh'', {asynchronous:true, > > evalScripts:true}); LOAD_FILE(vars...); return false;">lsls</a> > > sorry bout that, i meant (in the onclick section) : > > new Ajax.Updater(''dom_to_update'', ''/action/on/server/for/ajax'', > {asynchronous:true, evalScripts:true}); LOAD_FILE(<%= rubyvars %>); > return false; > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---