Multiple lines of statements are queued rather than being executed simultaneously. A callback function queues the statements and executes them one by one.
Its syntax is as follows:
var callbacks = $.Callbacks();
The object created can be used to add, remove, instantiate, and disable callbacks. The supported functions are callbacks.add()
, callbacks.remove()
, callbacks.fire()
, and callbacks.disable()
.
This function is used to add all the functions in an array that are to be called later.
The callbacks.add()
function adds the function to the callback array.
Here is an example of its usage.
Required jQuery Code:
function myFunc1( value ) { console.myLog( value ); } function myFunc2( value ) { console.myLog( "myFunc2 says: " + value ); return false; } var callbacks = $.Callbacks(); callbacks.add( myFunc1 ); // Outputs...