jQuery Callbacks disabled() Method

Beginner
5 min read
Updated: Oct 2026
5 examples
Live preview

What Is disabled()?

callbacks.disabled() tells you whether a Callbacks list has been disabled (since jQuery 1.7). The official API: determine if the callbacks list has been disabled. It returns a boolean and does not change the list.

Remember
callbacks.disabled()  → false  (fresh list)
callbacks.disable()
callbacks.disabled()  → true

// Read-only — does NOT call disable()
// No enable() exists
NeedUse
Ask “is it shut down?”cbs.disabled()
Shut it downcbs.disable()
Ask “is it locked?”cbs.locked()
Ask “has it fired?”cbs.fired()

How to Use disabled()

Call it whenever you need a clear yes/no before firing or subscribing.

  1. Create and use a Callbacks list as usual.
  2. Call disable() when the feature ends (teardown).
  3. Read status with disabled() — true means shut down.
  4. Use the boolean in guards, logs, or public plugin APIs.
PieceRequired?Role
Callbacks objectYesList to inspect
ArgumentsNonedisabled() takes no parameters
Return—true or false (Boolean)

Pseudocode

Pseudocode
list = Callbacks queue
disabledFlag = false

disable():
  disabledFlag = true

disabled():
  return disabledFlag   // read only — no side effects

// Typical guard:
if disabled():
  log "skip"
else:
  fire(args…)

Cheat Sheet

Keep these facts handy when checking Callbacks status.

TopicDetail
Syntaxcallbacks.disabled()
ArgumentsNone
ReturnsBoolean — true after disable()
Mutates?No — read-only
Fresh listfalse
vs disable()Action vs status check
SincejQuery 1.7

Live Preview

Compare fresh, disabled, and locked lists and see what disabled() reports.

Browser demo of callbacks.disabled — same ideas as the examples below.

Result
$.Callbacks()
disabled() → false

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — New List Returns false

A freshly created list is active until you call disable().

jQuery
var callbacks = $.Callbacks();

console.log("Disabled?", callbacks.disabled()); // false

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

callbacks.fire(); // → Handler runs
Try It Yourself

How It Works

  1. Create. $.Callbacks() starts with disabled = false.
  2. Read status. disabled() returns false.
  3. Add and fire. Handlers run normally.
  4. Rule. Until disable() runs, the list stays active.

Example 2 — After disable() Returns true

Call disable() first, then check status — not the other way around.

jQuery
var callbacks = $.Callbacks();

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

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

callbacks.fire();
// → Callback 1 executed
// → Callback 2 executed

callbacks.disable();
console.log("Disabled?", callbacks.disabled()); // true

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

How It Works

  1. First fire. Both handlers run while the list is active.
  2. Disable. The action that flips the internal flag.
  3. Read. disabled() now returns true.
  4. Second fire. No-op — status matches reality.

Example 3 — Guard Before fire()

Skip firing and log clearly when the list is already shut down.

jQuery
function safeFire(callbacks, args) {
  if (callbacks.disabled()) {
    console.warn("Callbacks list is disabled — skipping fire");
    return;
  }
  callbacks.fire.apply(callbacks, args);
}

var hooks = $.Callbacks();
hooks.add(function (msg) { console.log("Hook:", msg); });
hooks.disable();

safeFire(hooks, ["late call"]);
// → Callbacks list is disabled — skipping fire
Try It Yourself

How It Works

  1. Helper. safeFire asks disabled() first.
  2. Teardown. disable() shuts the list down.
  3. Late call. Guard logs and returns early.
  4. Why. Clearer than a silent no-op fire().

Example 4 — Plugin Exposes Status

Let consumers ask whether hooks are still live before subscribing.

jQuery
var AppBus = (function () {
  var events = $.Callbacks();

  return {
    on: function (fn) {
      if (events.disabled()) {
        console.log("Cannot subscribe — bus disabled");
        return;
      }
      events.add(fn);
    },
    emit: function (data) { events.fire(data); },
    shutdown: function () { events.disable(); }
  };
})();

AppBus.on(function (d) { console.log("Got:", d); });
AppBus.emit("hello");     // → Got: hello
AppBus.shutdown();
AppBus.on(function () {}); // → Cannot subscribe — bus disabled
Try It Yourself

How It Works

  1. Wrap the list. Public on / emit / shutdown.
  2. Normal use. Subscribe and emit while active.
  3. Shutdown. Calls disable() under the hood.
  4. Late subscribe. disabled() blocks the new handler with a clear message.

Example 5 — disabled() vs locked()

These status methods answer different questions about the same list.

jQuery
var locked = $.Callbacks();
locked.lock();
console.log("locked:", locked.locked());     // true
console.log("disabled:", locked.disabled()); // false

var disabled = $.Callbacks();
disabled.disable();
console.log("locked:", disabled.locked());     // false
console.log("disabled:", disabled.disabled()); // true
Try It Yourself

How It Works

  1. Locked list. locked() is true; disabled() stays false.
  2. Disabled list. disabled() is true; locked() stays false.
  3. Different flags. Do not use one to infer the other.
  4. Pick the right check for the action you care about (membership vs firing).

Edge Cases & Pitfalls

Check these before relying on disabled() in shared code.

verb

Name trap: disabled ≠ disable

disabled() never shuts the list down. Calling it alone leaves firing intact.

sticky

Stays true forever

After disable(), disabled() cannot return false again on that object. Create a new list if needed.

lock

Locked ≠ disabled

A locked list can still fire. Check locked() and disabled() separately.

optional

Guards are optional but useful

fire() on a disabled list is already safe. Use disabled() when you want logs or early returns.

fired

Not the same as fired()

fired() asks whether the list has been invoked at least once — unrelated to the disabled flag.

Browser Support

callbacks.disabled() is part of jQuery’s Callbacks API (since 1.7). It works in any browser where your jQuery build runs — the status flag lives in jQuery, not as a separate browser API.

✓ jQuery 1.7+ · Browsers

jQuery callbacks.disabled()

Supported in jQuery 1.x, 2.x, and 3.x across Chrome, Firefox, Safari, Edge, and other browsers with jQuery loaded.

100% With jQuery loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
callbacks.disabled() Browsers

Bottom line: Safe wherever jQuery is loaded. Pair with disable() for the action and disabled() for the status check.

Performance Notes

OperationCostBest for
disabled()O(1)Status checks and guards
disable()O(1)One-time teardown
Guard + fireO(1) + O(n)Shared helpers that need clear logs

Reading disabled() is a cheap boolean check. Use it freely in helpers. Avoid wrapping every single hot-path fire() unless you need the extra logging — the native no-op is already safe.

Key Takeaways

  • Role: disabled() answers “is this list shut down?”
  • Action: use disable() to flip the flag permanently.
  • Guards: check before fire/subscribe for clearer plugin APIs.
  • vs locked: different flag — check the one that matches your intent.

One line: disable() acts; disabled() asks.

Frequently Asked Questions

disabled() is a read-only status check. It returns true if disable() was called on the list, otherwise false. It does not disable anything itself — use disable() for the action.
disable() is the verb — it permanently shuts down the list. disabled() is the question — "is this list shut down?" It returns a boolean and leaves the list unchanged.
On a freshly created $.Callbacks() list, and on any list that has never had disable() called. Active lists that still accept fire() return false.
No. disabled() only reads state. jQuery provides no enable() method. Once disable() runs, disabled() stays true forever for that list object.
fire() on a disabled list is already a safe no-op, but checking disabled() first can avoid pointless calls and produce clearer logs in shared utilities or plugin code.
disabled() reflects whether disable() was called. locked() reflects whether lock() was called — a different state. A list can be locked but not disabled, or disabled but not locked.

Next: lock()

Freeze a Callbacks list so later fire() values are ignored.

lock() tutorial →

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.

7 people found this page helpful