Skip to content

Instantly share code, notes, and snippets.

@bitboxx
Last active August 29, 2015 14:25
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 bitboxx/37bbcefc66e5eafca263 to your computer and use it in GitHub Desktop.
Save bitboxx/37bbcefc66e5eafca263 to your computer and use it in GitHub Desktop.
jQuery live() and die() plugin
// jQuery live() and die() plugin for newer version jQuery (version newer than 1.7)
// meant to facilitate gradual upgrade of old jQuery code to a newer version
jQuery.fn.live = function (eventTypes, eventHandler) {
var that = $(this);
$(document).on(eventTypes, that['selector'], eventHandler);
return that;
};
jQuery.fn.die = function (eventTypes, eventHandler) {
var that = $(this);
$(document).off(eventTypes, that['selector'], eventHandler);
return that;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment