Answer the question
In order to leave comments, you need to log in
How to make a like button if there are a lot of posts?
Gentlemen, help a newbie and a noob, I can’t figure out what to do in such a situation: I wrote the code for the like button, everything works perfectly if the post (which is liked) is alone on the page.
jquery code:
$(function(){
$('span a').on('click', function(e){
e.preventDefault();
var url = this.href;
$.get(url, function(data){
$('#like').html('<img src="/static/countries/like.svg">' + data);
});
});
});
…
{% for description in descriptions %}
...
<span><a href="{% url 'countries:likes' description.id %}"><span id="like"><img src="..."> {{ description.likes.count }}</span></a></span>  men like it
<span id="like>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question