Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
- <span id="bookmark-count">1 people bookmarked this listing</span>
- function to_bookmarks()
- {
- var current = $(this);
- var type = current.data('type');
- var pk = current.data('id');
- var action = current.data('action');
- var t = null
- var count = $('#bookmark-count');
- $.ajax({
- url : "/bookmarks/" + type + "/" + pk + "/",
- type : 'POST',
- data : { 'pk' : pk },
- success : function (json) {
- if(json.count = 1){
- t = '1 person bookmarked this listing';
- } else {
- t = json.count + ' people bookmarked this listing';
- }
- count.text(t);
- }
- });
- return false;
- }
- $(function() {
- $('#bookmark-button').click(to_bookmarks);
- });
Add Comment
Please, Sign In to add comment