following button on site

This commit is contained in:
Kyle Drake 2014-05-05 15:25:25 -07:00
parent 51a85a0b03
commit 0a29a496d7
5 changed files with 62 additions and 18 deletions

View file

@ -0,0 +1,16 @@
var Site = {
toggleFollow: function(siteId, csrfToken) {
var link = $('a#followLink')
var span = $('a#followLink span')
$.post('/site/'+siteId+'/toggle_follow', {csrf_token: csrfToken}, function(res) {
console.log(res)
if(res.result == "followed") {
span.text('Unfollow')
link.removeClass('follow')
} else if(res.result == 'unfollowed') {
span.text('Follow')
link.addClass('follow')
}
})
}
}