callbacks.disable()S2C Home « Objects « callbacks.disable()

Disable a callbacks list.

Description

The callbacks.disable() Callbacks object method, disables a callback list.

Syntax

Signature Description
callbacks.disable()Disable a callback list.

Parameters

None.

Return

undefined

callbacks.disable() ExampleTop

Disable a callback list.

In the example below when we press the button the first time we add the aFunc(value, div) function to our callbacks list and then fire the list off. After this we disable the list and then try to add and fire the bFunc(value, div) function. Because the callback list is now disabled nothing happens.


$(function(){
  $('#btn7').one('click', function(){
    var ourCallbacks = $.Callbacks();
    ourCallbacks.add( aFunc );
    ourCallbacks.fire( 'The aFunc function was fired from our callbacks. <br>', '#div7');
    ourCallbacks.disable();
    ourCallbacks.add( bFunc );
    ourCallbacks.fire( 'The bFunc function was fired from our callbacks. <br>', '#div7');
  });
  function aFunc( value, div ){
    $(div).append( value);
  }
  function bFunc( value, div ){
    aFunc('Passing bFunc function value to aFunc. <br>', div);
  }
});

div7. Some initial text.

Press the button below to action the above code: