callbacks.fired()S2C Home « Objects « event.pageX

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

Boolean.

callbacks.fired() Examplego to top of page 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.

Press the button below to action the above code:



go to home page Homepage go to top of page Top