{"record":{"id":"a6503a9b1cb4637c","repo":"GrapesJS/grapesjs","slug":"spectrum-no-such-method-opts","errorCode":null,"errorMessage":"Spectrum: no such method: '\" + opts + \"'\"","messagePattern":"Spectrum: no such method: '\" \\+ opts \\+ \"'\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/utils/ColorPicker.ts","lineNumber":1213,"sourceCode":"  function inputTypeColorSupport() {\n    return $.fn.spectrum.inputTypeColorSupport();\n  }\n\n  /**\n   * Define a jQuery plugin\n   */\n  var dataID = 'spectrum.id';\n  $.fn.spectrum = function (opts, extra) {\n    if (typeof opts == 'string') {\n      var returnValue = this;\n      var args = Array.prototype.slice.call(arguments, 1);\n\n      this.each(function () {\n        var spect = spectrums[$(this).data(dataID)];\n        if (spect) {\n          var method = spect[opts];\n          if (!method) {\n            throw new Error(\"Spectrum: no such method: '\" + opts + \"'\");\n          }\n\n          if (opts == 'get') {\n            returnValue = spect.get();\n          } else if (opts == 'container') {\n            returnValue = spect.container;\n          } else if (opts == 'option') {\n            returnValue = spect.option.apply(spect, args);\n          } else if (opts == 'destroy') {\n            spect.destroy();\n            $(this).removeData(dataID);\n          } else {\n            method.apply(spect, args);\n          }\n        }\n      });\n\n      return returnValue;","sourceCodeStart":1195,"sourceCodeEnd":1231,"githubUrl":"https://github.com/GrapesJS/grapesjs/blob/2bdeda85b82b8b9ceae42fd6558cbbcae5ec2d21/packages/core/src/utils/ColorPicker.ts#L1195-L1231","documentation":"GrapesJS bundles a legacy Spectrum color picker jQuery plugin. Its jQuery method dispatcher looks up a method name on the spectrum instance and throws when the requested method string doesn't exist. This is an internal-library error usually surfaced when the picker is invoked with an unknown method or the component isn't fully initialized.","triggerScenarios":"Calling `$(el).spectrum('someMethod')` (or internal code invoking the picker with an options string) where `someMethod` isn't one of the supported methods ('get', 'container', 'show', 'hide', 'destroy', 'enable', 'disable', etc.), or invoking a method before the spectrum instance was created for that element.","commonSituations":"Custom color-input integrations calling spectrum APIs directly; race conditions where the picker method is called before init; version drift where a method was removed from the bundled Spectrum; typos in method names in custom RTE/asset-manager color setups.","solutions":["Use a valid Spectrum method name ('show', 'hide', 'get', 'set', 'container', 'enable', 'disable', 'destroy', 'option').","Ensure the color picker is initialized on the element before calling methods (the element must have a spectrum instance in the internal registry).","Avoid calling spectrum internals directly; use GrapesJS's editor APIs (e.g. style manager color inputs) instead.","If you need specific spectrum methods, bundle/replace the color picker via the appropriate GrapesJS custom-color-picker option."],"exampleFix":"// before\n$el.spectrum('colour'); // typo, not a spectrum method\n// after\nconst color = $el.spectrum('get');","handlingStrategy":"try-catch","validationCode":"const VALID = ['show','hide','toggle','set','get','container','enable','disable','option','destroy'];\nif (!VALID.includes(methodName)) throw new Error(`Unsupported spectrum method: ${methodName}`);\nconst inst = $el.data('spectrum-id') && spectrums[$el.data('spectrum-id')];\nif (!inst) throw new Error('Spectrum not initialized on this element');","typeGuard":"null","tryCatchPattern":"try {\n  const value = $el.spectrum('get');\n} catch (err) {\n  if (err.message.startsWith('Spectrum: no such method')) {\n    console.error('Init the color picker or use a valid method name');\n  } else throw err;\n}","preventionTips":["Only call documented Spectrum methods after the picker is initialized","Initialize the picker on the element before invoking methods (avoid init/use race conditions)","Prefer GrapesJS public APIs (style manager inputs) over calling spectrum directly","Keep GrapesJS and any custom color-picker overrides version-compatible"],"tags":["color-picker","jquery","api-misuse","legacy"],"backgroundTag":"no-such-method","analyzedSha":"2bdeda85b82b8b9ceae42fd6558cbbcae5ec2d21","analyzedAt":"2026-08-30T11:47:52.267Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}