callbacks.fired()
JQ Home <<
Objects <<
callbacks.fired()
Check for callbacks list invocation.
Description
The callbacks.fired()
Callbacks object method, allows us to determine whether the callback list has already been invoked.
Syntax
Signature | Description |
---|---|
callbacks.fired() | Determine whether the callback list has already been invoked. |
Parameters
None.
Return
A Boolean
object.
callbacks.fired()
Example
Objects << Top
Determine whether the callback list has already been invoked.
In the example below when we press the button the first time we add the aFunc(value, div)
and bFunc(value, div)
functions to our callbacks lists. We then alert whether they have been fired,
fire them off, and then test again whether they have been fired.
$(function(){
$('#btn9').one('click', function(){
var ourCallbacks = $.Callbacks();
ourCallbacks.add( aFunc );
ourCallbacks.add( bFunc );
$('#div9').append( 'Have callbacks been fired? ' + ourCallbacks.fired() + '<br>');
ourCallbacks.fire( 'The aFunc
function was fired from our callbacks. <br>', '#div9');
ourCallbacks.fire( 'The bFunc
function was fired from our callbacks. <br>', '#div9');
$('#div9').append( 'Have callbacks been fired? ' + ourCallbacks.fired() + '<br>');
});
function aFunc( value, div ){
$(div).append( value);
}
function bFunc( value, div ){
aFunc('Passing bFunc
function value to aFunc
. <br>', div);
}
});
div9. Some initial text.
Related Tutorials
jQuery Advanced Tutorials - Lesson 6 - The Callbacks Object