link_to_remote and :with

Hi

    I have in my view 2 variables
    @sd_resolution_id and @sd_ticket

How can I pass this t controller..I tried the following but failed
Please help

    <%= link_to_remote "Edit Resolution",
                            :update => "create_sd_resolution_ui",
                            :url => { :action =>
'define_sd_resolution_ui',
:with => "'sd_resolution_id='+ '@sd_resolution_id' + '&id=' +
escape($('@sd_ticket'))"),
                        %>

Thanks in advance
Sijo

Hi

   I have in my view 2 variables
   @sd_resolution_id and @sd_ticket

How can I pass this t controller..I tried the following but failed
Please help

   <%= link_to_remote "Edit Resolution",
                           :update => "create_sd_resolution_ui",
                           :url => { :action =>
'define_sd_resolution_ui',
:with => "'sd_resolution_id='+ '@sd_resolution_id' + '&id=' +
escape($('@sd_ticket'))"),

:with is a javascript fragment, so something like "{sd_resolution_id:
@sd_resolution_id, id: escape($('@sd_ticket'))}" is probably about
right.
  in this particular case, can't you just do

<%= link_to_remote "Edit Resolution",
                           :update => "create_sd_resolution_ui",
                           :url => { :action =>
'define_sd_resolution_ui', :id => @sd_ticket, :sd_resolution_id =>
@sd_resolution_id} %>

?
Fred

Sijo Kg wrote:

How can I pass this t controller..I tried the following but failed
Please help

    <%= link_to_remote "Edit Resolution",
                            :update => "create_sd_resolution_ui",
                            :url => { :action =>
'define_sd_resolution_ui',
:with => "'sd_resolution_id='+ '@sd_resolution_id' + '&id=' +
escape($('@sd_ticket'))"),
                        %>

:with is for passing in javascript ,not for passing parameters to the
URL. In all functions which create a URL, you can pass in extra
parameters in the URL specification part. In your example, you'd want
something like:

<%= link_to_remote "Edit Resolution",
          :update => "create_sd_resolution_ui",
          :url => {:action => :define_sd_resolution_ui,
                   :sd_resolution => @sd_resolution_id,
                   :id => @sd_ticket} %>

For more information have a look at the examples in the documentation:

http://api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper.html#M000958

Thanks for your replies

Mark Bush wrote:

:with is for passing in javascript ,not for passing parameters to the
URL.

Bit misleading there as I wasn't thinking right at the time. It *is*
for passing parameters, however it's mainly useful for passing
JavaScript values (or DOM values) as parameters.

You *can* use it for passing Rails values, but it's a bit ugly compared
to putting them in the :url hash.