<% @services.each do |service| %>
<div class="widget-content nopadding">
<ul class="activity-list">
<li>
<%= link_to service.company.name, "#", :id => 'specific_service' %>
</li>
</ul>
</div>
<% end %>
So, I have a list of various services which all have an id. the link_to displays the service's company name which performs the 'specific_service' javascript function. But I want it to display unique data according to the service's id. How do I pass in the service.id to the link_to in order for the controller to have access to the correct service?
EDIT
$('#specific_service').click(function(){
var id = $(this).data('id');
var _url = '<%= dashboard_specific_service_path(:format => :js) %>?start_date=' + encodeURI($('#start_date').val()) + '&end_date=' + encodeURI($('#end_date').val()) + '&service_id=' + id;
$.ajax({
type: 'GET',
url: _url,
dataType : 'script'
});
});
This is my javascript function which invokes a file called 'specific_service.js.erb' which would then render a partial called 'specific_service'. The thing is I don't know if I'm using the var id correctly.