Skip to content

Instantly share code, notes, and snippets.

@stevenwoodson
Created December 29, 2012 21:05
Show Gist options
  • Save stevenwoodson/4409372 to your computer and use it in GitHub Desktop.
Save stevenwoodson/4409372 to your computer and use it in GitHub Desktop.
jQuery - Custom binding on 'after'
// Trigger any custom bindings on after
(function($) {
var origAfter = $.fn.after;
$.fn.after = function () {
return origAfter.apply(this, arguments).trigger("after");
};
})(jQuery);
// Bind 'after' and then use it to trigger function_to_trigger()
$('.element').bind("after", function() { function_to_trigger(); } }).after('<ul></ul>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment