On Jun 13, 12:50 pm, Neil Bye <[email protected]> wrote:
> This is my form. It creates a comment in the database but won't pass the
> 'body' value. I think the problem is passing the variable to javascript.
> Can anyone help?
>
Your serialize_form method looks borked. You could use the
remote_form_for method alternatively, prototype already provides a
serialise method for forms - $('id_of_the_form').serialize() will
serialise all then inputs in the form
Fred
> <% form_for :comment, :url=>story_comments_path(@story), :name =>
> 'form' do |form| %>
> <fieldset>
> <label for="login">Comment:</label>
> <div id="body"><%= form.text_field :body %></div>
> <%= link_to_remote('comment',{ :url =>
> {:controller => 'comments' ,
> :action => 'create',
> :story_id => @story.id,
> :method => 'get',
> :with =>
> 'serialize_fields()' }}) %>
> </fieldset>
> <% end %>
>
> This is the javascript.
>
> <script>
> function serialize_fields(){
> var fields = new Array();
> fields.push(Form.Element.serialize('document.form.body'));
> return fields.join('&');}
>
> </script>
> --
> Posted viahttp://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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.