I am implementing a like functionality and here is the challenge I am having.
Once the user clicks on like, the js below runs and renders a string from the server, which is a partial view. Then I have unlike link/icon there to enable user to unlike it. But I cant click on it, ie; the link is dead, doesnt fire. DEAD.
$('.like-button').click(function() {
var btn = $(this);
var projectid = btn.attr('id').replace('like_', '');
$.post('/Projects/Like', {
projectid: projectid
}).done(function(data) {
if (data.likePart) {
$('#likepart_' + projectid).html(data.likePart);
}
});
return false;
});
EDIT:
This is the html:
{"likePart":"\u003cspan class=\"badge bg-aqua\" id=\"count_10\"\u003e\r\n 0\r\n\u003c/span\u003e\r
\n\r\n \u003ca href=\"#\" id=\"like_10\" class=\"like-button\"\u003e\r\n \u003ci class=\"fa
fa-heart-o\" style=\"color: #ff0000;\"\u003e\u003c/i\u003e\r\n \u003c/a\u003e\r\n\r\n\r\n\r\n\r\n
\u003cspan\u003e İlk beğenen siz olun.\u003c/span\u003e\r\n"}
How can I ensure that once the link returns, user can click on it?
Thanks.