You need to serialize the fields that you''d like to send to your
controller.
The serialized fields are sent using :with. Note the method
''get'' - this
won''t work with post.
link_to_remote(''Search'',
{ :url => {:controller => ''controller'',
:action =>
''action''},
:method => ''get'',
:with => ''serialize_fields()'',
:update => ''id of element to update'',
:complete => "..." })
<script>
function serialize_fields(){
var fields = new Array();
fields.push(Form.Element.serialize(''fieldname1''));
fields.push(Form.Element.serialize(''fieldname2''));
fields.push(Form.Element.serialize(''fieldname3''));
return fields.join(''&'');
}
</script>
Hammed
On 8/25/06, ry an
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> I''m trying to show a preview of the comments, and I''m
saving the
> comments through AJAX. So, I thought that I should be able to mimic the
> "comments" action for the "comments_preview" action
very easily. So
> far, this isn''t the case.
>
> I have a link_to_remote tag inside of the form tag, and I don''t
know how
> to send the parameters that are within the form (name, site, comment)
> and the id of the post it''s on (to get the current count of
entries, but
> that''s not as important). Basically, I don''t know how to
send the
> comment parameters using link_to_remote, so that I can use them in my
> controller like so:
>
> @comment = Comment.new(params[:comment])
>
> Then just use the @comment in the "comments_preview.rhtml" view
to
> display a preview... I was using the post id to get the
> Comment.count("post_id=#{params[:id]}").
>
> How can I send all of this data to the controller? Thanks!
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---