Forum: Ruby on Rails Ajax - adding to ul

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James R. (Guest)
on 2007-07-30 18:18
I have a form and a ul and the form is submitting a new li for the
unordered list.  It puts the right info into the MySQL database, but it
won't insert properly into the list.  Also, the link to show the form
stops working and it just says [object XMLHttpRequest] where the form
used to be and the unordered list is unchanged.

The view: http://pastie.caboo.se/83457.txt (Pastie, for some odd reason,
repeated some commas and >'s (like ,,,,, instead of , and =>>>>>>>>
instead of =>, hence the link to the txt version).

The method: http://pastie.caboo.se/83459

The partial used in add_todo_item: <li><%= link_to @item.name, :action
=> 'todo_item', :id => @item %></li>

The javascript update function: http://pastie.caboo.se/83461

I really have no idea what is wrong and trying to use Firebug in Firefox
(I generally use Camino) is useless because it ignores using Ajax and
tries actually going to a page.

Thanks in advanced.
Shandy N. (Guest)
on 2007-07-30 18:29
Try looking at link_to_remote

link_to_remote @item_name, :url => { :action => 'todo_item', :id =>
@item }, :update => 'your_list'

Im new to the ruby world myself, but, unless I'm mistaken, link_to
renders an entirly new page while link_to_remote works with the Ajax
functionality to render just a specific part in the page. The :update
attribute tells link_to_remote what part of the page, with that id, you
are updating. Hope this helps,

~S
James R. (Guest)
on 2007-07-30 19:29
I'm so dumb, I had TWO things with the id of "todo" (I forgot I had some
header stuff).  It works now.
This topic is locked and can not be replied to.