I have the following 2 links which are formed in a ruby rails .each do block:
<%= link_to "Reply", '#', class: 'reply-link', id: "reply-#{sender}" %>
<%= link_to "Resolved", '#', class: 'complete-link', id: "resolved-#{sender}" %>
I want to be able to do something like this but I'm not sure how to extract the rails record id (#{sender}) in the ajax post.
$('.reply-link').click(function(event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: '/messages/complete?sender='+$(this).attr("id")
});
});
The $(this).attr("id") above obviously returns reply-1 instead of 1
link_to "Reply", '#', class: 'reply-link', id: "reply-#{sender}"you're setting the id to "reply-number"?