Updated code, see below:
On Feb 23, 2006, at 5:21 PM, David Olbersen wrote:
> So I''m trying to do that hot new thing with AJAXy forms:
>
> http://idiet.toasterwaffles.com/foods/list
>
> Here''s the relevant code in list.rhtml (for the form portion)
>
> <tbody>
> <%= render_collection_of_partials "list_stripes", @foods
%>
> </tbody>
>
> <tfoot>
> <tr id="addFood"><%= form_remote_tag( :html =>
{''id'' =>
> ''createFoodForm''},
> :url => {:action =>
> ''create_with_ajax''},
> :update =>
''foodList'',
> :position =>
''bottom'',
> :complete => ''$
> (createFoodForm).reset();''
> ) %>
> <td class="txt"><%= text_field
''food'', ''name'' , "size"=>20
%
> ></td>
> <td class="num"><%= text_field
''food'', ''serving'' , "size"=>5
%
> ></td>
> <td class="txt"><%= text_field
''food'', ''units'' , "size"=>10
%
> ></td>
> <td class="num"><%= text_field
''food'', ''calories'', "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''fat'' , "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''sat_fat'' , "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''sodium'' , "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''carbs'' , "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''fiber'' , "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''sugars'' , "size"=>5
%
> ></td>
> <td class="num"><%= text_field
''food'', ''protein'' , "size"=>5
%
> ></td>
> <td><%= submit_tag "Add" %></td>
> </tr>
> </tfoot>
>
> and here''s the relevant code in foods_controller.rb
>
> def create_with_ajax
> @food = Food.new(params[:food])
> if @food.save
> render_partial "list_stripes"
else
render_text "Couldn''t create!"> end
> end
>
Now I get "Couldn''t create" all over the place!
> I''ve got a _list_stripes.rhtml partial that creates the table. The
> crazy part is that when I try creating a new item I get "Template
> is missing" -- which I don''t understand at all. If I change
the
> action in form_remote_tag to the default ''create'' method
I get back
> (in the table) an empty form, as if nothing had been passed in yet.
>
> Any ideas where I messed up? Thanks for reading this far!
>
> --
> David Olbersen
> dave@toasterwaffles.com
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
--
David Olbersen
dave@toasterwaffles.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060224/c4362750/attachment-0001.html