twbs/bootstrap · error · TypeError
No method named "${config}"
Error message
No method named "${config}" What it means
ScrollSpy's jQueryInterface applies the strict guard (method exists, no leading '_', not 'constructor'), and the component has exactly two public methods: refresh and dispose. refresh is the documented call after the monitored DOM changes (added/removed anchors); anything else — including update, which exists on Dropdown but not ScrollSpy — throws.
Source
Thrown at js/src/scrollspy.js:272
parent.classList.remove(CLASS_NAME_ACTIVE)
const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE}`, parent)
for (const node of activeNodes) {
node.classList.remove(CLASS_NAME_ACTIVE)
}
}
// Static
static jQueryInterface(config) {
return this.each(function () {
const data = ScrollSpy.getOrCreateInstance(this, config)
if (typeof config !== 'string') {
return
}
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
throw new TypeError(`No method named "${config}"`)
}
data[config]()
})
}
}
/**
* Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
ScrollSpy.getOrCreateInstance(spy)
}
})
/**View on GitHub (pinned to 6177d5f849)
Solutions
- After DOM changes, call scrollspy('refresh') — the only operational method besides dispose.
- Do not transfer 'update' from Dropdown to ScrollSpy.
- Use the vanilla API: bootstrap.ScrollSpy.getInstance(spyEl)?.refresh().
- Whitelist dynamic names to ['refresh', 'dispose'].
Example fix
// before
$('#spy').scrollspy('refreshList') // TypeError: No method named "refreshList"
// after
$('#spy').scrollspy('refresh') // refresh | dispose — call after adding/removing monitored elements Defensive patterns
Strategy: validation
Validate before calling
function callScrollSpyMethod(element, method) {
const instance = bootstrap.ScrollSpy.getOrCreateInstance(element)
const callable = typeof instance[method] === 'function' &&
!method.startsWith('_') && method !== 'constructor'
if (!callable) {
console.warn(`ScrollSpy: ignoring unknown method "${method}"`)
return
}
instance[method]()
} Type guard
const SCROLLSPY_METHODS = ['refresh', 'dispose'] as const type ScrollSpyMethod = (typeof SCROLLSPY_METHODS)[number] const isScrollSpyMethod = (m: string): m is ScrollSpyMethod => (SCROLLSPY_METHODS as readonly string[]).includes(m)
Try / catch
try {
$('#spy').scrollspy(method)
} catch (err) {
if (err instanceof TypeError && err.message.startsWith('No method named')) {
console.warn(`ScrollSpy: unknown method "${method}"`)
} else {
throw err
}
} Prevention
- After SPA/AJAX content changes, call scrollspy('refresh') — that is the only operational method.
- Do not transfer Dropdown's 'update' to ScrollSpy.
- Whitelist dynamic names to ['refresh', 'dispose'].
- Prefer bootstrap.ScrollSpy.getInstance(spyEl)?.refresh().
When it happens
Trigger: $('#spy').scrollspy('update') — Dropdown has update, ScrollSpy does not; $('#spy').scrollspy('refreshList'); $('#spy').scrollspy('_offsets') (private, rejected); $('#spy').scrollspy('constructor').
Common situations: SPAs re-rendering nav content and guessing the method name; reusing code written for Dropdown; forgetting that after AJAX content changes refresh() is the required call.
Related errors
- No method named "${config}"
- No method named "${config}"
- No method named "${config}"
- No method named "${config}"
- No method named "${config}"
AI-assisted analysis of twbs/bootstrap@6177d5f849 (2026-08-22).
Data as JSON: /api/errors/2923463d0c0c643c.
Report an issue: GitHub.