Ingo W. wrote:
I have a form generated with form_remote_tag that contains a selection
list. I would like to auto-submit the form when the user makes a choice
in the selection list, so I added an option :onchange =>
‘this.form.submit()’ to select_tag
Now what happens is that when I make a choice, the partial template
get’s rendered as expected, but not replacing the target div but the
entire window instead! The div replacement works just fine when I submit
the form using the submit button.
Why is that?
I’ve run into this before, the sad part is that I can’t remember how I
Your form is not being submitted via AJAX. All the magic of
form_remote_tag happens in the onsubmit property of the form tag. The
onsubmit is event is bypassed, yet it will work as expected via submit
submission, with no AJAX.
Perhaps you can call “$(‘submit-button’).click” or even
“this.form.onsubmit()” to directly call the events that make the magic
I think that’s how I solved it anyway.