jQuery Callbacks disable() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Callbacks

Definition

callbacks.disable() permanently shuts down a Callbacks list (since jQuery 1.7). The official API describes it as disabling the list from doing anything more. Afterward, fire() / fireWith() are no-ops. Returns the same Callbacks object for chaining.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
callbacks.add(fn)
callbacks.fire("foo")     // runs
callbacks.disable()
callbacks.fire("foobar")  // ignored — no output

disabled() → true after disable()
no enable() method exists
CallWhat it does
Callbacks objectList to shut down
Argumentsdisable() takes no parameters
ReturnSame Callbacks object (chainable)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Create and use a Callbacks list normally (add / fire).
Step 2When the feature ends (destroy, unmount, fatal error), call disable().
Step 3Optionally check disabled() in shared helpers before firing.

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.

jQuery Examples

Example 1 — Disable Before fire()

Register handlers, call disable(), then try to fire — nothing runs.

jQuery
var callbacks = $.Callbacks();

callbacks.add(function () {
  console.log("Callback 1");
});

callbacks.add(function () {
  console.log("Callback 2");
});

callbacks.disable();
callbacks.fire(); // no output
Try It Yourself

How It Works

  1. Register. Two handlers join the list.
  2. Disable. The list is shut down before any fire.
  3. Fire. Invocation is a no-op — nothing prints.

Example 2 — Disable After a Successful fire()

The first fire() runs; after disable(), later fires are ignored.

jQuery
var callbacks = $.Callbacks();

callbacks.add(function () {
  console.log("Runs once");
});

callbacks.fire();
// → Runs once

callbacks.disable();
callbacks.fire(); // ignored
Try It Yourself

How It Works

  1. First fire. Handler runs normally.
  2. Disable. Marks the list as permanently off.
  3. Second fire. No-op — matches the official docs example.

Example 3 — Guard With disabled()

Check status before firing in shared helper code.

jQuery
var callbacks = $.Callbacks();

function safeFire(list) {
  if (list.disabled()) {
    console.log("Skipped — list disabled");
    return;
  }
  list.fire();
}

callbacks.add(function () {
  console.log("Handler");
});

callbacks.disable();
safeFire(callbacks);
// → Skipped — list disabled
Try It Yourself

How It Works

  1. Helper. safeFire reads disabled() first.
  2. Disable the list. Status flips to true.
  3. Call the helper. It logs and returns early.

Frequently Asked Questions

disable() permanently shuts down a Callbacks list. After calling it, fire() and fireWith() become no-ops — they return without invoking handlers. The official description is: disable a callback list from doing anything more.
No. jQuery has no enable() method. disable() is one-way. To fire again, create a fresh $.Callbacks() list or keep your own pause flag outside Callbacks.
lock() freezes the handler set — no more add() or remove() — but fire() still runs existing handlers. disable() stops all future firing. lock() protects the queue; disable() kills it.
Treat disable() as final teardown. Further add() and fire() calls are effectively ignored. Check disabled() when debugging missing handlers.
Call disabled() — it returns true after disable() has run. That is the read-only status check; disable() is the action that turns firing off.
Common cases: plugin destroy/unmount, shutting down an event bus after app teardown, or blocking stray fires after a one-time workflow completes. Pair with disabled() in defensive helpers.

Next: callbacks.disabled() Method — Check List Status

Learn how to read whether a Callbacks list has already been shut down.

callbacks.disabled() Method — Check List Status tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful