jQuery callbacks.fire()Method
Example
Call all callbacks with the specified arguments
$(function () {
//A simple function that will be added to the list
var foo = function( value ) {
alert( "foo:" + value );
};
var callbacks = $.Callbacks();
//Add function "foo" to the list
callbacks.add( foo );
//Call all callbacks in the list with the given arguments
callbacks.fire( "hello" ); //Output: "foo: hello"
callbacks.fire( "world" ); //Output: "foo: world"
//Add another function to the list
var bar = function( value ){
alert( "bar:" + value );
};
//Add this function to the list
callbacks.add( bar );
//Call all callbacks in the list with the given arguments
callbacks.fire( "hello again" );
//Output:
// "foo: hello again"
// "bar: hello again"
})
Try it Yourself »
Definition and Usage
The callbacks.fire() function is used to call all callbacks with the specified arguments.
This method returns a callback object to the callback list to which it is bound.
Syntax
callbacks.fire( arguments )
| Parameters | Description |
|---|---|
| arguments | Any Type The argument or list of arguments passed back to the callback list. |
Other Extensions
jQuery Miscellaneous Methods