Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Putting JQuery into application.js causes remote forms to submit twice #60

Closed
DVG opened this issue Jun 13, 2012 · 4 comments
Closed

Putting JQuery into application.js causes remote forms to submit twice #60

DVG opened this issue Jun 13, 2012 · 4 comments

Comments

@DVG
Copy link

DVG commented Jun 13, 2012

I ran into an interesting problem where I had a remote form:

#index.html.erb#quick_reply
<%= simple_form_for [@discussion, @post], :remote => true do |f| %>
  <%= f.input :body, :input_html => {:class => 'span12 short_text_area' } %>
  <%= f.submit 'Post Reply', :class => 'btn-primary' %>
<% end %>

And when the form submitted, it was processed twice. I ended up fixing by removing

//= require jquery
//= require jquery_ujs

from my application.js file. This is in exact opposition with what this gem's documentation says, but it seems that I'm getting the JQuery scripts without having them in the manifest file. Does the doc need updated or is there something else going on here?

@JangoSteve
Copy link
Member

Do you have a //= require_tree or //= require_directory elsewhere in your manifest file?

@DVG
Copy link
Author

DVG commented Jun 13, 2012

Hmm yes, I have a require_tree . at the bottom. Is that the issue? I haven't manually added anything, but twitter bootstrap might have put it there

@JangoSteve
Copy link
Member

I think require_tree is requiring the jquery and jquery_ujs files, which is why if you add those lines, you're actually requiring it twice.

@DVG
Copy link
Author

DVG commented Jun 15, 2012

Figured it out. I had forgotten I ran assets:precompile in dev once, so everything was getting served from public/assets and app/assets. My bad.

@DVG DVG closed this as completed Jun 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants