ender-remove
Version:
Monkey-patch bonzo to trigger a remove event when elements are removed from the DOM
26 lines (24 loc) • 709 B
JavaScript
// Generated by CoffeeScript 1.3.1
(function($) {
var empty, remove, replaceWith, triggerRemoveEvent, _ref;
_ref = $(''), empty = _ref.empty, remove = _ref.remove, replaceWith = _ref.replaceWith;
triggerRemoveEvent = function(els) {
els.deepEach(function(el) {
$(el).trigger('remove').unbind();
});
};
return $.ender({
empty: function() {
triggerRemoveEvent(this.children());
return empty.apply(this, arguments);
},
remove: function() {
triggerRemoveEvent(this);
return remove.apply(this, arguments);
},
replaceWith: function() {
triggerRemoveEvent(this);
return replaceWith.apply(this, arguments);
}
}, true);
})(ender);