Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
globals.js
function HeartButton(){
this.user = whi.currentUser();
this.entry = false;
}
HeartButton.prototype.renderIn = function($dom){
var $img = $dom.find('img');
this.entry = new whi.Entry();
this.entry.id = $img.data('entry');
var $button = $('button');
$button.addClass('heartButton');
$button.data('entry', this.entry.id);
$button.data('user', this.user.id)
$button.append($div);
$button.on('click', function(that){
$.ajax('weheartit.com/entry/heart', {entry: that.entry, user: that.user}, function(response){
if(response.success){
$button.addClass('hearted');
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment