jQuery callbacks.fire() method
Example
Invoke all callbacks with the given arguments
$
(
function
(
)
{
//
A simple function to be added to the list
var
foo
=
function
(
value
)
{
alert
(
"
foo:
"
value
)
;
}
;
var
callbacks
= $.
Callbacks
(
)
;
//
Add the 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 »
Definition and Usage
The callbacks.fire() function is used to call all callbacks with the specified arguments.
This method returns a callbacks object to the callback list it is bound to.
Syntax
callbacks.fire( arguments )
| Parameters | Description |
|---|---|
| arguments | Any type: an argument or list of arguments passed back to the callbacks |
jQuery Miscellaneous Methods