<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 17, 2014 at 12:42 PM, Andrew Stewart <span dir="ltr"><<a href="mailto:boss@airbladesoftware.com" target="_blank">boss@airbladesoftware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 17 Jan 2014, at 13:22, Alexander Hockey-Sweeney <<a href="mailto:alexsween@gmail.com">alexsween@gmail.com</a>> wrote:<br>

> The submit handler has been bound twice<br>
<br>
</div>Is there any way to inspect what events are bound and/or fired when the form is submitted?<br></blockquote><div><br></div><div><b>Chrome developer tools has an event listener section that shows all functions bound to particular events</b></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
>  - So potentially a double include of the javascript file<br>
<br>
</div>Looking at what's loaded in production via Chrome's Network tab, I only see my "all.js" once.<br></blockquote><div><b>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.</b></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
>  - extra javascript that handles a submit or click, potentially meant for another part of the application<br>
<br>
</div>If this were the case, wouldn't the double-submit always happen rather than intermittently (once a week or so)?<br></blockquote><div><b>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.</b></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> Clicking versus hitting enter<br>
> - event binding for click vs. hitting enter might be different (you'll get double in one instance, but not the other)<br>
<br>
</div>I'll look into this...<br>
<div class="im"><br>
> Format of request<br>
> - Are both requests js or is one js and one html? Likely indicator that there is a double binding<br>
<br>
</div>Both are HTML according to the Rails log.<br>
<div class="im"><br>
> Redirects<br>
> - do you have any redirects set-up in your application? Sometimes respond_with automatically redirects unexpectedly (depending on the format of the request)<br>
<br>
</div>No, the application just renders an HTML partial.<br></blockquote><div><b>Curious, why are you specifying an html data type instead of js? What is supposed to happen when you submit the form?</b></div></div><br></div>
</div>