Semantic-Org/Semantic-UI · error
The method you called is not defined
Error message
The method you called is not defined
What it means
This error is logged by the API module's invoke function (api.js:942-985) when a method name passed to $('.element').api('nonexistent.method') does not match any property in the module object. The invoke function traverses the module object by splitting the query string on dots/periods and camelCasing; if no matching key is found at any depth, it logs this error. It is the API module equivalent of site.js's method-not-found error.
Source
Thrown at src/definitions/behaviors/api.js:1132
// failed JSON success test
onFailure : function(response, $module) {},
// server error
onError : function(errorMessage, $module) {},
// request aborted
onAbort : function(errorMessage, $module) {},
successTest : false,
// errors
error : {
beforeSend : 'The before send function has aborted the request',
error : 'There was an error with your request',
exitConditions : 'API Request Aborted. Exit conditions met',
JSONParse : 'JSON could not be parsed during error handling',
legacyParameters : 'You are using legacy API success callback names',
method : 'The method you called is not defined',
missingAction : 'API action used but no url was defined',
missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',
missingURL : 'No URL specified for api event',
noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',
noStorage : 'Caching responses locally requires session storage',
parseError : 'There was an error parsing your request',
requiredParameter : 'Missing a required URL parameter: ',
statusMessage : 'Server gave an error: ',
timeout : 'Your request timed out'
},
regExp : {
required : /\{\$*[A-z0-9]+\}/g,
optional : /\{\/\$*[A-z0-9]+\}/g,
},
className: {
loading : 'loading',View on GitHub (pinned to 597843ab84)
Solutions
- Consult the Semantic UI API module documentation for the correct method name.
- Inspect the module object at runtime to discover valid method names.
- Ensure the element is actually initialized with the API module before calling methods.
Example fix
// before
$('.api-element').api('set.load'); // typo
// after
$('.api-element').api('set.loading'); Defensive patterns
Strategy: type-guard
Validate before calling
// Validate method name before invoking on the API module
var apiMethods = ['query','abort','reset','set.loading','remove.loading','set.error','remove.error','get.request','get.xhr','is.loading','is.disabled','is.mocked','create.request','create.mockedXHR'];
if (apiMethods.indexOf(methodName) !== -1) {
$('.el').api(methodName);
} else {
console.warn('Unknown API method:', methodName);
} Type guard
// Type guard for API module methods
function isValidApiMethod(name) {
// Split and traverse the module object dynamically
var parts = name.split(/[.\s]/);
var obj = $('.el').data('module-api');
return parts.every(function(p) { return obj && (obj = obj[p]) !== undefined; });
} Prevention
- Consult the API module documentation for valid method names.
- Store method names as constants to avoid typos.
- Verify the element is initialized with the API module before invoking methods.
When it happens
Trigger: Calling $('.el').api('nonexistent'), $('.el').api('set.loading.extra') where 'set.loading' exists but 'extra' does not, or any method name that does not exist in the API module's method map. Also triggered by typos in method invocations.
Common situations: Typographical errors, version differences where method names changed, calling a method from a different Semantic UI module on an API-initialized element, or copy-pasting deprecated API examples.
Related errors
- The method you called is not defined.
- The before send function has aborted the request
- There was an error with your request
- API Request Aborted. Exit conditions met
- JSON could not be parsed during error handling
AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13).
Data as JSON: /api/errors/f6a416ceff5b031c.
Report an issue: GitHub.