22 March Form_remote_tag submit by Javascript
When you try to submit a form from Javascript, using form_remote_tag, like this:
Rails:
form_remote_tag :url => {:controller => "somecontroller", :action => "} , :html => {:id => "ajax-form-1">
If you just invoke form.submit(), like this:
var form = document.getElementById('ajax-form-1'); if(form) form.submit();
the form will be submitted to a new page, that’s not soo ajaxy you now think. Instead use:
var form = document.getElementById('ajax-form-1');<br /> if(form.onsubmit()){ form.submit(); }
Now your form will be submitted on the AJAX way!
6 Comments - Tags: Ajax, form


