callbacks.fire(arguments) runs every handler on a jQuery Callbacks list (since jQuery 1.7), in add order, with the arguments you pass. It returns the same Callbacks object for chaining.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
callbacks.add(foo)
callbacks.fire("hello") // foo("hello")
callbacks.fire("world") // foo("world") again
add() → queue handlers
fire() → run them now
returns the Callbacks object (chainable)
Call
What it does
Callbacks object
From $.Callbacks()
arguments
Values forwarded to each handler
Return
Same Callbacks object (chainable)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Create a list with $.Callbacks() (optional flags such as once).
Step 2
Register handlers with add(fn).
Step 3
Call fire(arg1, arg2, …) to run every handler with those args.
Return Value
Return Value
Description
Boolean
Often true or false depending on the match or state.
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — Fire With Arguments
Official style: add one handler, then fire twice with different values.
jQuery
var foo = function (value) {
console.log("foo: " + value);
};
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.fire("hello"); // foo: hello
callbacks.fire("world"); // foo: world
var lines = [];
var foo = function (value) { lines.push("foo: " + value); };
var bar = function (value) { lines.push("bar: " + value); };
var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.add(bar);
callbacks.fire("hello again");
console.log(lines.join("\\n"));
// foo: hello again
// bar: hello again
fire() calls every function currently registered on the Callbacks list, in registration order. Any arguments you pass to fire() are forwarded to each handler. It returns the same Callbacks object for chaining.
Use fire(args…) when you only need to pass arguments. Use fireWith(context, argsArray) when handlers must run with a custom this value (for example a DOM element or plugin object).
fire() completes with no errors and no handlers run. Safe, but easy to miss if you expected subscribers.
No. After disable(), fire() is a no-op. Check disabled() when debugging silent fires.
Yes on a default list — each fire() runs all current handlers again. With $.Callbacks("once"), only the first fire() has effect.
Yes. After a successful fire, fired() returns true. That matters for flags like memory (late add() can replay the last arguments).