The fire() method is how you run a jQuery Callbacks list — it calls every registered handler in order and passes along any arguments you supply. This tutorial covers syntax, five examples, comparisons with add() and fireWith(), and edge cases like empty or disabled lists.
01
Syntax
callbacks.fire(args)
02
add()
Register first
03
Order
FIFO execution
04
Args
Shared payload
05
fireWith()
Custom this
06
Events
Pub/sub trigger
Fundamentals
Introduction
Callback lists are useless until something triggers them. In jQuery’s Callbacks API, that trigger is fire() (or its sibling fireWith() when you need a custom this value).
Typical flow: create a list with $.Callbacks(), register handlers via add(), then call fire() when your event occurs — data loaded, button clicked, plugin initialized. Every subscriber runs with the same arguments you pass to fire().
Concept
Understanding the fire() Method
callbacks.fire([arg1 [, arg2 ...]]) synchronously invokes each function in the list. Handlers run in the order they were added. If a handler returns false and the list was created with the stopOnFalse flag, remaining callbacks are skipped.
fire() does nothing when the list is empty, disabled, or locked in a state that prevents firing. It does not throw — which makes defensive checks with disabled() optional but helpful for logging.
💡
Beginner Tip
Always add() handlers before fire() unless you use the memory flag and plan to fire first — a pattern covered in the $.Callbacks() tutorial.
Foundation
📝 Syntax
General form of callbacks.fire:
jQuery
callbacks.fire( [ arg1 [, arg2 ... ] ] )
Parameters
arg1, arg2, … (optional) — values forwarded to every callback as positional arguments.
Plugins often hide the raw Callbacks object and expose on/emit wrappers — emit internally calls fire().
Applications
🚀 Use Cases
Custom events — trigger subscriber callbacks on user actions or data changes.
Plugin lifecycle — fire onInit, onDestroy, or onUpdate hook lists.
Async completion — fire when a timer, animation, or mock AJAX step finishes.
Pipeline stages — pass shared context objects through ordered handlers.
Testing — fire lists in unit tests to verify subscribers react correctly.
🧠 How fire() Works
1
Subscribe
Handlers register with add() and wait in a queue.
add()
2
fire()
jQuery loops the queue, calling each function with your arguments.
Invoke
3
Flags apply
once, stopOnFalse, and memory alter repeat and replay behavior.
Rules
=
▶
Coordinated execution
One trigger, many listeners — the core pub/sub pattern in jQuery.
Important
📝 Notes
fire() runs synchronously — long handlers block until they finish.
Handlers added during a fire (from inside another handler) may run in the same invocation — behavior depends on list state; avoid unless intentional.
After disable(), fire() is always a no-op.
Use fireWith(element, [args]) when handlers need this to be a DOM node.
fired() tells you whether the list has fired at least once — useful with once lists.
Compatibility
Browser Support
callbacks.fire() is part of jQuery’s Callbacks API since jQuery 1.7 and works wherever jQuery runs.
✓ jQuery 1.7+
jQuery Callbacks.fire()
Supported in jQuery 1.x, 2.x, and 3.x across all browsers with a compatible jQuery build.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
callbacks.fire()Universal
Bottom line: Safe in jQuery projects. Pair with add() for subscribe and fire() for publish.
Wrap Up
🎉 Conclusion
The callbacks.fire() method is the trigger that makes Callbacks lists useful — it runs every registered handler with the arguments you provide. Master the add-then-fire workflow, know when to use fireWith(), and respect list flags like once and stopOnFalse.
Next, learn fired() to check whether a list has been invoked, and fireWith() for custom this binding.
Pick Callbacks flags for once or memory when needed
❌ Don’t
Fire before any subscribers register (unless using memory)
Run heavy blocking work inside fire handlers without notice
Assume fire throws when the list is empty
Confuse fire() with fireWith()
Fire disabled lists expecting side effects
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about fire()
The publish step in jQuery Callbacks.
5
Core concepts
▶01
fire()
Run all handlers
API
+02
add()
Subscribe first
Queue
1,2,303
Order
FIFO
Sequence
📦04
Args
Shared data
Payload
🔌05
emit()
Pub/sub pattern
Pattern
❓ Frequently Asked Questions
fire() invokes every handler currently registered on the Callbacks list, in registration order. Optional arguments you pass to fire() are forwarded to each callback function.
Use fire(args...) when the default this value (the Callbacks list in strict mode, or window in sloppy mode) is fine. Use fireWith(context, args) when handlers need a specific this — such as a DOM element or plugin instance.
Nothing runs — fire() completes silently with no errors. This is safe but can hide logic bugs if you expected handlers to exist.
No. disable() permanently shuts down the list. fire() becomes a no-op and disabled() returns true.
Yes, on a default Callbacks list. Each fire() runs all current handlers again. With the once flag on $.Callbacks("once"), only the first fire() has effect.
It returns the same Callbacks object, so you can chain: callbacks.fire(data).add(fn) — though adding after firing is less common than firing after add().
Did you know?
jQuery’s internal naming mirrors this API: fire() runs handlers, and fired() reports whether firing ever happened — the same action/status pairing as disable() / disabled().