Chris S
2008-Jun-26 18:53 UTC
submit button with an onclick attribute set doesn''t work in opera
I have the following code inside a form that submits via XHR: <button id="finalize_button" type="submit" onclick="finalizing();">Finalize Order</button> finalizing() basically changes the button text and disables the button while the form is submitting. Works as expected in FF, but in Opera 9.5, the button gets disabled but the form fails to submit. If I remove the onclick attribute it works fine. Any suggestions for a workaround? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Edward Grant
2008-Jun-26 18:58 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
> I have the following code inside a form that submits via XHR: > > <button id="finalize_button" type="submit" > onclick="finalizing();">Finalize Order</button> >Make sure you return true from the onclick function like this <button id="finalize_button" type="submit" onclick="finalizing(); return true;">Finalize Order</button> if the onclick returns false it will prevent the default behavior of the submit button -- Edward Grant themasternone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org RPGA #342155 CAMARILLA #US2002022579 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Chris S
2008-Jun-26 19:34 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
That didn''t work - thanks for the suggestion though. On Jun 26, 1:58 pm, "Edward Grant" <themastern...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have the following code inside a form that submits via XHR: > > > <button id="finalize_button" type="submit" > > onclick="finalizing();">Finalize Order</button> > > Make sure you return true from the onclick function > > like this > > <button id="finalize_button" type="submit" onclick="finalizing(); > return true;">Finalize Order</button> > > if the onclick returns false it will prevent the default behavior of > the submit button > -- > Edward Grant > themastern...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > RPGA #342155 > CAMARILLA #US2002022579--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Polgardy
2008-Jun-26 19:39 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
Wait, it''s a form that submits via XHR? How is the XHR hooked in, through the finalizing() function? Would help to see the rest of the code. -Fred On Thu, Jun 26, 2008 at 2:34 PM, Chris S <chris.sepic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > That didn''t work - thanks for the suggestion though. > > On Jun 26, 1:58 pm, "Edward Grant" <themastern...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have the following code inside a form that submits via XHR: > > > > > <button id="finalize_button" type="submit" > > > onclick="finalizing();">Finalize Order</button>-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Chris S
2008-Jun-26 19:45 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
Here''s the <form> tag created by form_remote_tag: <form action="/some/path" method="post" onsubmit="new Ajax.Request(''/ some/path'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> Maybe I could manually trigger the forms onsubmit handler? How would I do that? On Jun 26, 2:39 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Wait, it''s a form that submits via XHR? How is the XHR hooked in, through > the finalizing() function? Would help to see the rest of the code. > > -Fred > > On Thu, Jun 26, 2008 at 2:34 PM, Chris S <chris.se...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > That didn''t work - thanks for the suggestion though. > > > On Jun 26, 1:58 pm, "Edward Grant" <themastern...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have the following code inside a form that submits via XHR: > > > > > <button id="finalize_button" type="submit" > > > > onclick="finalizing();">Finalize Order</button> > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Justin Perkins
2008-Jun-26 19:46 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
On Thu, Jun 26, 2008 at 1:53 PM, Chris S <chris.sepic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> finalizing() basically changes the button text and disables the button > while the form is submitting. Works as expected in FF, but in OperaIf you disable a submit button before the form onsubmit event actually fires, the form will not submit in IE and apparently, Opera. You need to disable the submit button *after* the form onsubmit event has occurred. This is typically achieved by adding an onStart() handler to your Ajax request. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Polgardy
2008-Jun-26 19:46 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
You can''t really do that. $(myForm).submit() doesn''t actually call the onsubmit handler. Why can''t you do all the hook logic in your form submit handler, and then conditionally allow the submit to proceed if it checks out? -Fred On Thu, Jun 26, 2008 at 2:45 PM, Chris S <chris.sepic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Here''s the <form> tag created by form_remote_tag: > > <form action="/some/path" method="post" onsubmit="new Ajax.Request(''/ > some/path'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this)}); return false;"> > > Maybe I could manually trigger the forms onsubmit handler? How would I > do that?-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Justin Perkins
2008-Jun-26 19:51 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
On Thu, Jun 26, 2008 at 2:46 PM, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is typically achieved by adding an onStart() handleronStart is nothing, I mean onLoading. <form onsubmit="new Ajax.Request(''/foo/bar'', { onLoading:function(){ $(''submit_button'').disable(); } })"> ... <input type="submit" id="submit_button" value="submit" /> </form> (untested) -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Chris S
2008-Jun-26 20:03 UTC
Re: submit button with an onclick attribute set doesn''t work in opera
Justin/Frederick - Thanks, that did the trick. Here''s my updated code: <% form_remote_tag( :url => {:controller => ''store'', :action => ''finalize_order'', :location_id => @location.id}, :before => "finalizing();") do %> ... <% end %> That generates <form action="/some/path" method="post" onsubmit="finalize(); new Ajax.Request(''/ some/path'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> which is exactly what I was after. On Jun 26, 2:46 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Jun 26, 2008 at 1:53 PM, Chris S <chris.se...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > finalizing() basically changes the button text and disables the button > > while the form is submitting. Works as expected in FF, but in Opera > > If you disable a submit button before the form onsubmit event actually > fires, the form will not submit in IE and apparently, Opera. You need > to disable the submit button *after* the form onsubmit event has > occurred. This is typically achieved by adding an onStart() handler to > your Ajax request. > > -justin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---