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

Empty a callbacks list.


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


Signature Description
callbacks.empty()Empty a callback list.





callbacks.empty() ExampleTop

Empty a callback list.

In the example below when we press the button the first time we add the aFunc(value, div) and the bFunc(value, div) functions to our callbacks list. After this we empty the list and then try to fire the callbacks list. Because the callback list has been emptied nothing happens.

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

div8. Some initial text.

Press the button below to action the above code: