bit new to Ajax and rails.
I have a link on an image that when clicked should replace the image.
Here's my link in the view:
<div id="flag_<%= message.id %>">
<%= link_to image_tag("white_star.png"), flag_message_path(message), remote: true %>
</div>
this calls flag method on messages controller. For format.js i have flag.js:
{$('#flag_<%[email protected]%>').html('<% if @message.flag == false %><a href="/messages/96/flag" data-remote="true"><img alt="White_star" src="/assets/white_star.png" title="flag"></a>
<% else %>
<a href="/messages/96/flag" data-remote="true"><img alt="Red_star" src="/assets/red_star.png" title="flag"></a>
<% end %>');
}
this returns to the browser:
{
$('#flag_94').html('<a href="/messages/96/flag" data-remote="true"><img alt="White_star" src="/assets/white_star.png" title="flag"></a>
');
}
which seems ok to me, yet nothing happens.... Any thoughts?? thanks