Skip to content

Instantly share code, notes, and snippets.

@togakangaroo
Created January 25, 2012 15:59
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 togakangaroo/1676930 to your computer and use it in GitHub Desktop.
Save togakangaroo/1676930 to your computer and use it in GitHub Desktop.
Javascript functions returning functions - when you're being an asshole
cell.draggable({
helper: "clone",
start: function() { _.each(self.selection(), function(s){ s.cell.addClass('dragged')}) },
stop: function() { _.each(self.selection(), function(s){ s.cell.removeClass('dragged')}) }
});
// Looks good but I can clean that up!
var applyDrag = function(op){
return function() { _.each(self.selection(), function(s){ s.cell[op+'Class']('dragged')}) }
};
cell.draggable({
helper: "clone",
start: applyDrag('add'),
stop: applyDrag('remove')
});
// *Maybe* I'm just being an asshole here?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment