I have the following javascript which turns a table row into a link:
$("tr[data-link]").click(function() {
window.location = $(this).data("link")
})
Used for this table:
<tr data-link="<%= vendor_order_path(order) %>">
<td class="center"><%= order.created_at %></td>
....
<td class="center">
<div class=""><%= order.fulfillment_status %>
<a href="" class="form-show">Edit</a></div>
<div class="form-hide">
<%= form_for order do |f| %>
<%= f.text_field :tracking_numbers %>
<%= f.submit "Update Tracking" %>
<% end %>
</td>
</tr>
It works fine and how it's supposed to but my issue is the "Edit" for the form on the bottom can't be clicked without the above JS firing and linking to a new page...which uses this javascript:
$(document).on('turbolinks:load', function(){
$('a.form-show').click(function(event){
event.preventDefault();
$(this).parent().next('div.form-hide').toggle();
});
});
I can't click "Edit" without the other javascript link redirect happening.
How can I make it so when I press "Edit" the other javascript doesn't fire? Or somehow layer it down under the Edit?
I like the way it functions as I have the table highlight with the mouse pointer and allowing users to click to link_to the "show" page of the item they click.. But I also need the Edit to work as well.
What can i do?