Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turbolinks won't let me submit form without reloading page

I am using bootstrap 3 with turbolinks and the problem is, when I press on Submit button in my edit form nothing happens, but if I reload page every input submits just fine. I don't understand why this happens, I'm not even using javascript in my form. Here is the code:

<div class = "row">
  <%= semantic_form_for @post do |f| %>
  <%= f.semantic_errors %>
  <div class = "form-group">
    <div class = "col-lg-9 col-md-7">   
      <%= f.input :title, :label => "Title" %>
      <%= f.input :content, :as => :rich, :allow_embeds => true %>
      <%= f.input :cat_list, :label => "Type your tags here" %>
    </div>
  <div class = "col-lg-3 col-md-4 ">
      <p>
      <%= image_tag(@post.thumbnail.url(:original), :class => "img-thumbnail") %>
      </p>
      <p>
      <%= f.input :thumbnail, as: :file %>
      </p>
      <p>
      <%= f.select :tag_list, Post::Tags, { }, { :multiple => true, :size => 10, :class => "form-control" } %>
      </p>
    </div>
  <%= f.action :submit, :as => :button, :button_html => { :class => "btn btn-primary" } %>
</div>
  <% end %>
<%= link_to 'Show', @post %> |
<%= link_to 'Back', posts_path %>

This is the content of my application.js:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .
like image 986
John Davis Avatar asked Oct 20 '22 16:10

John Davis


1 Answers

I had a similar problem: whenever arriving at a page using link_to, I had to refresh.

Add data-no-turbolink="true" inside your view's body tag.

Was solved by looking at Form Submit button only works after reload.

like image 170
TaylorT Avatar answered Oct 23 '22 17:10

TaylorT