Forum: Ruby on Rails Trigger ajax form submission with drop_receiving_element

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.
6719a2ee05da4c03415c86200d84eaab?d=identicon&s=25 Maxime Guilbot (maximeg)
on 2006-04-27 17:40
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.
This topic is locked and can not be replied to.