I was looking through new stuff added to jQuery 1.7 and I saw they now have jQuery.Callbacks() http://api.jquery.com/jQuery.Callbacks/.
The documentation shows you how
I can see callbacks being useful when you are updating different DOM elements using the same method(s).
Here is a cheesy example: http://jsfiddle.net/UX5Ln/
var clickCallbacks = $.Callbacks();
clickCallbacks.add(function() {
var c = parseInt(this.text(), 10);
this.text(c + 1);
});
clickCallbacks.add(function(id) {
$('span', '#last').text(id);
});
$('.click').click(function() {
var $ele = $(this).next('div').find('[id^="clickCount"]');
clickCallbacks.fireWith($ele, [this.id]);
});
It updates the click counter and the 'last clicked' when you click on something.