callbacks.empty()
S2C Home « Objects « callbacks.empty()
Empty a callbacks list.
Description
The callbacks.empty()
Callbacks object method, empty a callback list.
Syntax
Signature | Description |
---|---|
callbacks.empty() | Empty a callback list. |
Parameters
None.
Return
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.
$(function(){
$('#btn8').one('click', function(){
var ourCallbacks = $.Callbacks();
ourCallbacks.add( aFunc );
ourCallbacks.add( bFunc );
ourCallbacks.empty();
ourCallbacks.fire( 'The aFunc function was fired from our callbacks. <br>', '#div8');
ourCallbacks.fire( '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.