40
Since jQuery 1.4.2+ changes how event handlers are stored, this seems relevant:
The best way I found was to use event namespacing:
var ary_handlers = [ fn_highlight, fn_onpress, fn_cleanup ];
for ( idx = 0; idx < ary_handlers.length; idx++ ){
$('#test').bind('click.foobar',ary_handlers[idx]);
}
// and then later:
$('#test').unbind('.foobar');
In the above example, all foobar events unbound. Notice that if you needed finer grain control, you could namespace each click handler and correlate to your array of handlers:
var ary_handlers = [ fn_highlight, fn_onpress, fn_cleanup ];
for ( idx = 0; idx < ary_handlers.length; idx++ ){
$('#test').bind('click.ns_' + String(idx), ary_handlers[idx]);
}
// and then later you could pick off a specific one to unbind
$('#test').unbind('.ns_2');