Skip to content

Instantly share code, notes, and snippets.

@pwmckenna
Created December 18, 2012 00:35
Show Gist options
  • Save pwmckenna/4323827 to your computer and use it in GitHub Desktop.
Save pwmckenna/4323827 to your computer and use it in GitHub Desktop.
liveOnce extension to backbrace.js's live function
(function() {
var liveOnceExtension = {
liveOnce: function(selectors, callback, context) {
var _this = this;
var wrapper = function() {
_this.die(selectors, wrapper, context);
callback.apply(this, arguments);
}
this.live(selectors, wrapper, context);
}
};
_.extend(Backbone.Model.prototype, liveOnceExtension);
_.extend(Backbone.Collection.prototype, liveOnceExtension);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment