Railsers: What does :with do in _remote calls, like link_to_remote() or periodically_call_remote()? The documentation says :with should point to: ''A JavaScript expression specifying the parameters for the XMLHttpRequest. This defaults to ''value'', which in the evaluated context refers to the new field value. If you specify a string without a "=", it''ll be extended to mean the form key that the value should be assigned to. So :with => "term" gives "''term''=value". If a "=" is present, no extension will happen.'' What does all that mean?? I need to take the value from a hidden field and pass this with the _remote call. Is that what with is for? When I naively turn it on (with the name of the hidden field as a string) the periodically_call_remote() stops working. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Phlip,>I need to take the value from a hidden field and pass this with the >_remote call. Is that what with is for?Yes. Are you passing the *id* of the hidden filed in :with? If that doesn''t work, try: :with => "Form.Element.serialize(\''id_of_hidden_field\'')", :method => ''get'' Note that the :method needs to be set to ''get'' (case sensitive) or it won''t work. Cheers Hammed On 11/13/06, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Railsers: > > What does :with do in _remote calls, like link_to_remote() or > periodically_call_remote()? > > The documentation says :with should point to: > > ''A JavaScript expression specifying the parameters for the > XMLHttpRequest. This defaults to ''value'', which in the evaluated > context refers to the new field value. If you specify a string without > a "=", it''ll be extended to mean the form key that the value should be > assigned to. So :with => "term" gives "''term''=value". If a "=" is > present, no extension will happen.'' > > What does all that mean?? > > I need to take the value from a hidden field and pass this with the > _remote call. Is that what with is for? When I naively turn it on > (with the name of the hidden field as a string) the > periodically_call_remote() stops working. > > -- > Phlip > http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hammed Malik wrote:> :with => "Form.Element.serialize(\''id_of_hidden_field\'')",Thanks! Someone had to tell me "the remote caller will evaluate the :with target as javascript, hence it can pull live data from your DOM." :with => ''id_of_hidden_field'' didn''t work, and I suppose I could have done something like ''document.all.id_of.value''. But your scriptalicious Form.Element.serialize() worked. I''m not sure why it puts a "_"=>nil into the params, though, but that''s too small to be worth optimizing away! -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You should be able to do something like :with => "''name='' + escape($F(''hidden_id''))" in your remote to pass on the value of a hidden field with an ID of "hidden_id" with your _remote call. It will be available in your method as params[''name'']. For example: <%= link_to_remote ''click here'', {:update => ''some_element'', :with => "''name='' + escape($F(''hidden_id''))"}, :url => {:action => ''my_method''} -%> David Phlip wrote:> Railsers: > > What does :with do in _remote calls, like link_to_remote() or > periodically_call_remote()? > > The documentation says :with should point to: > > ''A JavaScript expression specifying the parameters for the > XMLHttpRequest. This defaults to ''value'', which in the evaluated > context refers to the new field value. If you specify a string without > a "=", it''ll be extended to mean the form key that the value should be > assigned to. So :with => "term" gives "''term''=value". If a "=" is > present, no extension will happen.'' > > What does all that mean?? > > I need to take the value from a hidden field and pass this with the > _remote call. Is that what with is for? When I naively turn it on > (with the name of the hidden field as a string) the > periodically_call_remote() stops working. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---