twbs/bootstrap · error · TypeError

No method named "${config}"

Error message

No method named "${config}"

What it means

Popover reuses Tooltip's method surface through class inheritance, and its jQueryInterface throws when the string is not found on the instance (simple undefined check). Public methods are show, hide, toggle, enable, disable, toggleEnabled, update, setContent and dispose. The content API added in 5.2 is setContent — updateContent does not exist.

Source

Thrown at js/src/popover.js:83

      [SELECTOR_CONTENT]: this._getContent()
    }
  }

  _getContent() {
    return this._resolvePossibleFunction(this._config.content)
  }

  // Static
  static jQueryInterface(config) {
    return this.each(function () {
      const data = Popover.getOrCreateInstance(this, config)

      if (typeof config !== 'string') {
        return
      }

      if (typeof data[config] === 'undefined') {
        throw new TypeError(`No method named "${config}"`)
      }

      data[config]()
    })
  }
}

/**
 * jQuery
 */

defineJQueryPlugin(Popover)

export default Popover

View on GitHub (pinned to 6177d5f849)

Solutions

  1. Use the inherited Tooltip methods: show, hide, toggle, enable, disable, toggleEnabled, update, setContent, dispose.
  2. Replace 'destroy' with 'dispose' (v5 rename).
  3. Use setContent({ '.popover-body': '...' }) for dynamic content, not updateContent.
  4. Validate dynamic names against bootstrap.Popover.getInstance(el) before calling.

Example fix

// before
$('#pop').popover('updateContent', 'Hi') // TypeError: No method named "updateContent"

// after
$('#pop').popover('setContent', { '.popover-body': 'Hi' })
Defensive patterns

Strategy: validation

Validate before calling

function callPopoverMethod(element, method, ...args) {
  const instance = bootstrap.Popover.getOrCreateInstance(element)
  if (typeof instance[method] !== 'function') {
    console.warn(`Popover: ignoring unknown method "${method}"`)
    return
  }
  instance[method](...args)
}

Type guard

const POPOVER_METHODS = ['show', 'hide', 'toggle', 'enable', 'disable', 'toggleEnabled', 'update', 'setContent', 'dispose'] as const
type PopoverMethod = (typeof POPOVER_METHODS)[number]
const isPopoverMethod = (m: string): m is PopoverMethod =>
  (POPOVER_METHODS as readonly string[]).includes(m)

Try / catch

try {
  $('#pop').popover(method)
} catch (err) {
  if (err instanceof TypeError && err.message.startsWith('No method named')) {
    console.warn(`Popover: unknown method "${method}"`)
  } else {
    throw err
  }
}

Prevention

When it happens

Trigger: $('#pop').popover('updateContent', {...}) — correct is setContent; $('#pop').popover('destroy') — v4 name, v5 is dispose; $('#pop').popover('open'); $('#pop').popover('setContentX').

Common situations: v4→v5 migrations ('destroy' → 'dispose'); developers guessing updateContent because setContent arrived mid-5.x; mixing Tooltip/Popover verbs with other UI libraries.

Related errors


AI-assisted analysis of twbs/bootstrap@6177d5f849 (2026-08-22). Data as JSON: /api/errors/fbeacb93dbcabebc. Report an issue: GitHub.