[LRUG] Double submit

Alexander Hockey-Sweeney alexsween at gmail.com
Fri Jan 17 04:57:12 PST 2014


On Fri, Jan 17, 2014 at 12:42 PM, Andrew Stewart
<boss at airbladesoftware.com>wrote:

> On 17 Jan 2014, at 13:22, Alexander Hockey-Sweeney <alexsween at gmail.com>
> wrote:
> > The submit handler has been bound twice
>
> Is there any way to inspect what events are bound and/or fired when the
> form is submitted?
>

*Chrome developer tools has an event listener section that shows all
functions bound to particular events*

>
> >  - So potentially a double include of the javascript file
>
> Looking at what's loaded in production via Chrome's Network tab, I only
> see my "all.js" once.
>
*You could check your js manifests for double includes. If it's only
happening rarely, is it possible you include certain javascript in certain
cases (e.g. to accommodate a particular browser / device)? Given you're
using the remote: true, I assume you're using the rails javascript helpers,
so throwing some breakpoints into that code and seeing if there are edge
cases where it executes twice might be useful.*

>
> >  - extra javascript that handles a submit or click, potentially meant
> for another part of the application
>
> If this were the case, wouldn't the double-submit always happen rather
> than intermittently (once a week or so)?
>
*If you track the devices / browsers using the form, it might be worth
looking into which devices you see occasionally to identify ones that are
causing issues. I.e. the ones that perhaps break the rails_ujs javascript.*


>
> > Clicking versus hitting enter
> > - event binding for click vs. hitting enter might be different (you'll
> get double in one instance, but not the other)
>
> I'll look into this...
>
> > Format of request
> > - Are both requests js or is one js and one html? Likely indicator that
> there is a double binding
>
> Both are HTML according to the Rails log.
>
> > Redirects
> > - do you have any redirects set-up in your application? Sometimes
> respond_with automatically redirects unexpectedly (depending on the format
> of the request)
>
> No, the application just renders an HTML partial.
>
*Curious, why are you specifying an html data type instead of js? What is
supposed to happen when you submit the form?*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140117/1d479180/attachment-0003.html>


More information about the Chat mailing list