Trigger ajax form submission with drop_receiving_element


#1

Hello everyone!

I have a little problem with ruby on rails and ajax.

I have 2 sort of droppable items, 2 drop_receiving_element areas working
fine; but instead of updating a div, I would like to have a form
submitted with an ajax call. got it? (not so easy to explain)

My solution was to add a complete action submitting the form like this:

<%= drop_receiving_element “list”,
:url => { :action => “add” },
:accept => “categories”,
:loading => “Element.show(‘indicator’)”,
:complete => “new Ajax.Updater(‘list’, ‘/review/refresh’,
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(document.listform)});Element.hide(‘indicator’)”%>

the action ‘add’ add my element to the list, my ‘listform’ form is
refreshed by submitting the form through the ‘/review/refresh’ action.

it works well like this but, this make 2 ajax calls (‘add’ and
‘/review/refresh’) and the indicator disappear at the end of the first
action, not the second action.

How to do with one ajax call / in a cleaner way?

In my program, the user ‘build’ a custom form using drag-and-drop.
If the user begins to fill the form and after add an element, if I don’t
save the content of the form, the form is resetted.

If you didn’t catch what I mean, don’t hesitate to ask me more
informations.

Thanks for your help,
Maxime.