I have do each loop for a bunch of items that users can vote on. The items are listed on the index page, with each item as a button that opens up a Bootstrap modal on click. I want the user to be able to vote on the item within the modal, however I'm having difficulty accomplishing this. Here's what I have:
$(function () {
$(".box-inner").click(function() {
$('#modal_title').empty();
id = $(this).data('id');
url = window.location.origin + '/my_items/' + id + '/get_modal_content';
$.ajax({
cache: false,
type: 'GET',
url: url,
data: id,
complete: function() {
$.getJSON(url, function (data) {
$('#modal_title').append(data.name);
$('#myModal').attr("data-id", id);
});
},
success: function(data)
{
$("#myModal").modal('show');
}
});
});
});
Here is what the modal looks like:
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="modal_title"></h3>
</div>
<div class="modal-body">
<div class="technique-info-section">
<h3>Info</h3>
<span class="thumbs-up">
<%= link_to like_my_item_path(**???**), method: :put, :remote => true do %>
<i class="fa fa-thumbs-o-up"></i>
<% end %>
</span>
<span class="thumbs-down">
<%= link_to dislike_my_item_path(**???**), method: :put, :remote => true do %>
<i class="fa fa-thumbs-o-down"></i>
<% end %>
</span>
</div>
</div>
</div>
</div>
</div>
And here is what the .each loop looks like:
<% @techniques.each do |technique| %>
<li class="technique-box-outer">
<button class="box-inner" data-id="<%= technique.id %>">
<p class="technique-name"><%= technique.name %></p>
</button>
</li>
<% end %>
So in the two link_to paths in the modal, how can I get the link_to helper methods to have the correct item from the @techniques .each loop so that I can pass those params to my controller?