I create a jQuery Tool’s Overlay on a trigger as such:
$('button').overlay(
{
...
});
How can I disable and re-enable the overlay later on ? I want my $('button') element to remain as a link, but instead of displaying the Overlay on click, I want to show an alert ?
Something like that :
if( needToDisableOverlay() )
{
$('button').overlay().disable(); // no such thing...
$('button').bind( 'click.alert', function()
{
alert( 'The overlay has been disabled' );
});
}
// later on
if( needToEnableOverlay() )
{
$('button').unbind( 'click.alert' );
$('button').overlay().enable(); // no such thing...
}
I know I can use
$('button').unbind('click');
to remove all click handlers from the button (including the Overlay load() function), but I don’t think this is a clean way of doing it especially if I have other click handlers I want to maintain.
Maybe I can use flag in the Overlay’s onBeforeLoad handler and return false if the flag is set ?
What is the proper of achieving this ?
Answering my own question:
This works nicely, and looks clean. No unbinding required.
I guess I should have tried before posting — then again, maybe this will help other people in the future 😉