[Rails] submitting forms help

Peter Michaux
Mon, 10 Apr 2006 02:58:58 -0000

On 4/9/06, Manish Shah <mnshah@gmail.com> wrote:
> i had a different idea that i''m trying to get right.  Each sub
form is using
> form_remote_tag to make an ajax call onsubmit. What i did was create a
> javascript function that loops through all the forms and calls
> document.forms [i].submit()

That is an interesting idea but I''d stay away from it since a simpler,
bug-free solution exists. JavaScript is hard work.

>From what you''ve written it is possible that you have nested

tags? Is this true?

> However, its not acting as if the person clicked the submit button for each
> form.  I have :loading and :complete attributes set for each subform that
> shows the user that the form was submitted and the server result,
i''d like
> each of these to be triggered when calling document.forms[i].submit() which
> i thought it would since they are triggered with the onsubmit event.
>

> document.forms[i].submit()

Instead of this, what you really want to do is simulate a click event
on each submit button. Or something. Or you want to call with
JavaScript the same function you have in the onclick attribute of each
form submit. Things are getting complicated!

Good luck.

Peter