leppert/remotipart

Double Submit

Closed this issue · 12 comments

Seems like any time the form is submitted with a file selected, it calls the controller action twice (and inserts two records). Has anyone seen this? Thanks in advance.

I haven't had that problem, nor heard of it before now. Do you have a live example?

Off the top of my head, I'd say, make sure that neither the remotipart.js, nor the rails.js file are not being included twice in the layout. Also, if you recently upgraded to Rails 3.1, note that the rails.js (aka jquery_ujs.js) file is vendored in the jquery-rails gem, so if you left the rails.js in your assets directory, and upgraded to jquery-rails v1.0, it'd be included twice.

Have you been able to figure out what was happening with this? I'm going to go ahead and close this ticket, but please let me know if it's still an issue and I can re-open it.

mleung, I'm having the same double submit issue. Were you able to get it resolved?

JangoSteve, neither remotipart.js nor rails.js are being included twice. I'll try to set up an example that I can share with you.

@mleung, that would be great. In the meantime, maybe check out the example Rails 3.0 and 3.1 apps.

Well I feel like a horse's ass. Despite my insistence that neither JS files were being included twice...well, needless to say, they were.

Thanks for your help @JangoSteve.

Haha, nice, no prob. Glad you got it working :-)

me too, included jquery_ujs twice!

I'm having this issue as well ( using Rails 3.1.3 ):

I'm currently able to avoid the duplicate by doing a if remotipart_submitted? check in the controller, since the duplicate POST doesn't include the remotipart_submitted param.

Here's the js files in my app - is ujs include in the first jquery.js? Sorry, I'm sort of new to web development :)

jquery
jquery_ujs
jquery.iframe-transport
jquery.remotipart
best_in_place
jquery.purr
jquery.tokeninput
jquery-ui-1.8.18.custom.min
jquery-ui-timepicker-addon
jquery.form

@mhancock743, what are you using jquery.form for? Most of the jquery form plugin duplicates jquery-ujs and remotipart functionality.

So jquery.form is the source of the duplicates? OK great. My reason, however, for using it is as a workaround for a seperate issue I'm having with the browser not executing the response script. So, maybe I will open that up as a separate issue.

Thanks btw - remotipart part is an awesome gem.

edit - my original issue was resolved and all is right in the world again: JangoSteve#12 (comment)

Ooops, I meet the same problem...two submits, one is JS, one is JSON

Started PUT "/admin/organizations/15" for 127.0.0.1 at 2013-05-23 14:46:08 +0800
Processing by Admin::OrganizationsController#update as JSON
...

Started PUT "/admin/organizations/15" for 127.0.0.1 at 2013-05-23 14:46:08 +0800
Processing by Admin::OrganizationsController#update as JS
...

Rails 3.2.12