Skip to content

Instantly share code, notes, and snippets.

@johnnysparks
Created October 3, 2014 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnysparks/ed6d6f921da8bc186695 to your computer and use it in GitHub Desktop.
Save johnnysparks/ed6d6f921da8bc186695 to your computer and use it in GitHub Desktop.
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