How to make a link containing 'link_to_remote' call and exec

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”)

  1. 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.

lsls

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;

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
}

lsls

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 R. [email protected]