Ajax and submit

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Ajax and submit

Ken Barnes
Hey Ben, Awesome work on the prototype change.  How am i supposed
to submit the
form this way? as if i wanted to redirect or forward the user to
another page
because when if i have two submit buttons one uses ajax the other
does not when
i click the submit button that does not use ajax it does nothing.  
Thanks for reply


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Ajax and submit

Ken Barnes
if i refresh the page and hit the non-ajax button it will
submit as many times
but if i hit the ajax button then try the non-ajax
button it wont send the request.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Ajax and submit

Ben Gunter
Take a look first line in the invoke function:
function invoke(form, event, container) {
  if (!form.onsubmit) { form.onsubmit = function() { return false } };
  var params = Form.serialize(form, {submit:event});
  new Ajax.Updater(container, form.action, {method:'post', parameters:params});
}
That line effectively disables the normal form submit function. If a form's onsubmit returns false, then the form will not submit. When you click the normal submit button first, the form has no onsubmit and so it happily does its thing. The first time you click that AJAX submit button, though, it creates an onsubmit that returns false.

What you have to do is ensure that the form's onsubmit is null (or returns true) when the normal submit button is clicked. One way would be to add onclick="this.form.onsubmit=null" to your normal submit button.

-Ben

Ken Barnes wrote:
if i refresh the page and hit the non-ajax button it will 
submit as many times
but if i hit the ajax button then try the non-ajax 
button it wont send the request.
  

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users