# Ajax - adding to ul

**URL:** <https://www.ruby-forum.com/t/ajax-adding-to-ul/110748>\
**Category:** Rails\
**Created:** [July 30, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/ajax-adding-to-ul/110748 "2007-07-30T16:18:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [July 30, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/ajax-adding-to-ul/110748/1 "2007-07-30T16:18:23Z")

</div>

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: [Parked at Loopia](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: [Parked at Loopia](http://pastie.caboo.se/83459)

The partial used in add\_todo\_item:

- \<%= link\_to @item.name, :action  
=\> ‘todo\_item’, :id =\> @item %\>

The javascript update function: [Parked at Loopia](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.

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [July 30, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/ajax-adding-to-ul/110748/2 "2007-07-30T16:29:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [July 30, 2007, 5:29pm UTC](https://www.ruby-forum.com/t/ajax-adding-to-ul/110748/3 "2007-07-30T17:29:08Z")

</div>

I’m so dumb, I had TWO things with the id of “todo” (I forgot I had some  
header stuff). It works now.
