I have to modify site that is using jQuery's ready handler, I wan't to reuse code and not have to write it again, however I need to change the behaviour of original ready handler, the question is:
best regards
Ok, apparently you can't unbind the ready handler, to be precise, you can't when the ready() is used but you can using the bind('ready', handler) so instead of
$(document).ready(handler);
use
$(document).bind('ready', handler);
then whenever you want to change the existing event handler use:
$(document).unbind('ready', handler);//when there is reference to the handler
or
$(document).unbind('ready');//to remove all handlers for ready event
as I've recently found you can add the event namespace:) to only remove ready events in that namespace (i've peeked the jplayer code) as follows:
var GD_EVENT_NAMESPACE = ".GrelaDesign";
$document.bind('ready' + GD_EVENT_NAMESPACE, function(){ alert('ready'); });
//later
$document.unbind('ready' + GD_EVENT_NAMESPACE);//this will remove only specific events
best regards
p.s. I was searching extensively before asking here:) and soon after I've asked I've found on bing the answer:-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With