jQuery Callbacks disabled() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Callbacks

Definition

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.

Syntax

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

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

// Read-only — does NOT call disable()
// No enable() exists
CallWhat it does
Callbacks objectList to inspect
Argumentsdisabled() takes no parameters
Returntrue or false (Boolean)

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 as usual.
Step 2Call disable() when the feature ends (teardown).
Step 3Read status with disabled() — true means shut down.

Return Value

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

jQuery Examples

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.

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.

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.

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: callbacks.lock() Method — Freeze List State

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

callbacks.lock() Method — Freeze List State 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.

7 people found this page helpful