I have an index page that builds a table, and I am trying to allow users to edit line\'s in the table. I am trying to do this in the most basic way possible - no javascript
Try putting data-no-turbolink="true" into the link that called the table page.
<a href="/vender" data-no-turbolink="true">
That works form me.
This type of error is most frequently one generated by invalid HTML. Various sources of errors can be:
<
or >
</div>
s lying about...table
or tr
tags (within td
is allowed)The form helpers need to be properly nested, otherwise these quirks will bite you...
I believe this is an HTML issue, not a Rails issue. Per this discussion Form inside a table, <form>
can not be placed inside <table>
or <tbody>
or <tr>
. After moving the <form>
to wrap the table and putting the controls inside the respective <td>
the form works.
I still don't understand why refreshing the page made the form work, but...
If it's Rails 4, it's probably because of Turbolinks. Try putting
data-no-turbolink="true" inside your body tag
This may work, it happend once to me.
For rails 5, try using data: { turbolinks: false }
inside any links to the page containing the form.
E.g. <%= link_to "Get in Touch", 'contact', data: { turbolinks: false } %>
I have to share my experience :
I played with Turbolinks, like you. But suddently, I had an issue : the previous pages needed to have turbolinks disabled too, to work.
After many & many & many hours on the issue, I found the solution :
<% f.submit %>
was separated by 2 <div>
from the rest of the form !
Here is an example:
Wrong:
<div class="container">
<div class="row">
<!-- Inscription -->
<div class="col-lg-8 contact_col">
<div class="get_in_touch">
<div class="section_title">Modifier une marque</div>
<div class="contact_form_container">
<%= form_for @brand, url: {action: "update"} do |f| %>
<div class="row">
<div class="col-xl-12">
<!-- Name -->
<label for="contact_name">Nom de la marque</label>
<%= f.text_field :brand, class: "contact_input" %>
</div>
<div class="col-xl-12 last_name_col">
<span>
<%= f.label "Image de la marque" %><br />
</span>
<%= f.file_field :brand_picture %>
</div>
</div>
</div>
</div>
<button class="newsletter_button trans_200">
<%= f.submit "Modifier" %>
</button>
<% end %>
</div>
</div>
</div>
Correct:
<div class="container">
<div class="row">
<!-- Inscription -->
<div class="col-lg-8 contact_col">
<div class="get_in_touch">
<div class="section_title">Modifier une marque</div>
<div class="contact_form_container">
<%= form_for @brand, url: {action: "update"} do |f| %>
<div class="row">
<div class="col-xl-12">
<!-- Name -->
<label for="contact_name">Nom de la marque</label>
<%= f.text_field :brand, class: "contact_input" %>
</div>
<div class="col-xl-12 last_name_col">
<span>
<%= f.label "Image de la marque" %><br />
</span>
<%= f.file_field :brand_picture %>
</div>
</div>
<button class="newsletter_button trans_200">
<%= f.submit "Modifier" %>
</button>
<% end %>
</div>
</div>
</div>
</div>
</div>