Created
January 25, 2012 15:59
-
-
Save togakangaroo/1676930 to your computer and use it in GitHub Desktop.
Javascript functions returning functions - when you're being an asshole
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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