Guest User

Untitled

a guest
Jun 28th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. {% block jquery %}
  2. $("#po-like").click(function(event){
  3. event.preventDefault();
  4. $.ajax({
  5. url: $("#po-like-href").attr('href'),
  6. success: function(){
  7. },
  8. error: function(response, error){
  9. }
  10. })
  11. });
  12. {% endblock %}
  13.  
  14. {% for post in tape %}
  15. ...
  16. {{ post.text }}
  17. ...
  18. <a id="po-like-href" href="/like_post/{{ post.id }}/">
  19. <img id="po-like" src="{% static "" %}"/>
  20. </a>
  21. {% endfor %}
  22.  
  23. {% block jquery %}
  24. $(".po-like").click(function(event){
  25. //changing #id to .class
  26. //added the below line
  27. var img = $(this);
  28. event.preventDefault();
  29. $.ajax({
  30. url: img.parent().attr('href'),
  31. success: function(){
  32. },
  33. error: function(response, error){
  34. }
  35. })
  36. });
  37. {% endblock %}
  38. {% for post in tape %}
  39. ...
  40. {{ post.text }}
  41. ...
  42. //changing #id to .class
  43. <a class="po-like-href" href="/like_post/{{ post.id }}/">
  44. <img class="po-like" src="{% static "" %}"/>
  45. </a>
  46. {% endfor %}
Add Comment
Please, Sign In to add comment