Passing a value to js.erb

Rails 3.1.3

I'm trying to pass a value to 'save.js.erb' .

in the view, I have put

  <%= hidden_field_tag "video-id", @video.id, { :id => "video-id" } %>

then, I can retrieve it by

        var idval = $('#video-id').val();

It certainly gets the value.

The problem is then I need to pass it to the following. I tried,

$('#listtrans').html('<%= escape_javascript(render :partial => "videos/script_list", :locals => { :scripts => Script.find_all_by_video_id( idval ) } ) %>'); //<= idval

this does not work.

$('#listtrans').html('<%= escape_javascript(render :partial => "videos/script_list", :locals => { :scripts => Script.find_all_by_video_id(' + idval + ') } ) %>');

does not work either because of escape_javascript.

This seems simple, but I can't figure it out.

Could anyone help me out?

soichi