Weird shopping cart behaviour!

Dear all,

I have a general form (which I generate via form_tag) for a 'subscription'.

Inside this form the user can add 'elements' to his subscription. I do this with an an additional Ajax form:

<% form_remote_tag :url => { :action => :add_to_cart, :id => element } do%>   <%= submit_tag "Add" %> <% end %>

Every time the user adds an element to the cart (subscription) a table is updated with the list of already selected elements. In this table for every row another ajax form is created (rendered by a partial) to let the user remove the item:

<% form_remote_tag :url => { :action => :delete_from_cart, :id => element } do%>   <%= submit_tag "Remove" %> <% end %>

Now, the weird behaviour we find is the following:

1. I we select several elements and proceed to remove them one by one, we find the first Ajax Remove Form (the first button on the list) does not work. Instead of making an Ajax submit (as the rest of the buttons do) it does a regular global form submit.

2. Looking at the html code we see that for all buttons but the first, the Ajax submit form is created (for the first we have only the sumbmit button, but no Ajax form)

3. If we reload the page, all buttons work fine.

Any clues? Or maybe someone has implemented this proccess (add_to_cart, generate table with removal buttons before global submit) in some way it worked...

Thanks in advance!

Complex answer: You f*cked up the DOM. Simple solution: Lose the table.