Guest User

Untitled

a guest
May 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <button data-id="1" data-type="listing" data-action="bookmark" id="bookmark-button" class="like-button"><span class="like-icon"></span> Bookmark this listing</button>
  2. <span id="bookmark-count">1 people bookmarked this listing</span>
  3.  
  4. function to_bookmarks()
  5. {
  6. var current = $(this);
  7. var type = current.data('type');
  8. var pk = current.data('id');
  9. var action = current.data('action');
  10. var t = null
  11. var count = $('#bookmark-count');
  12.  
  13. $.ajax({
  14. url : "/bookmarks/" + type + "/" + pk + "/",
  15. type : 'POST',
  16. data : { 'pk' : pk },
  17.  
  18. success : function (json) {
  19. if(json.count = 1){
  20. t = '1 person bookmarked this listing';
  21. } else {
  22. t = json.count + ' people bookmarked this listing';
  23. }
  24. count.text(t);
  25. }
  26. });
  27.  
  28. return false;
  29. }
  30.  
  31. $(function() {
  32. $('#bookmark-button').click(to_bookmarks);
  33. });
Add Comment
Please, Sign In to add comment