{"record":{"id":"922631f1531ffe22","repo":"dotnet/AspNetCore.Docs","slug":"this-type-template-option-must-consist-of-exa-922631","errorCode":null,"errorMessage":"${this.type} `template` option must consist of exactly 1 top-level element!","messagePattern":"(.+?) `template` option must consist of exactly 1 top-level element!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"aspnetcore/mvc/controllers/testing/samples/3.x/TestingControllersSample/src/TestingControllersSample/wwwroot/js/bootstrap.js","lineNumber":1690,"sourceCode":"      var o  = this.options\n  \n      title = $e.attr('data-original-title')\n        || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)\n  \n      return title\n    }\n  \n    Tooltip.prototype.getUID = function (prefix) {\n      do prefix += ~~(Math.random() * 1000000)\n      while (document.getElementById(prefix))\n      return prefix\n    }\n  \n    Tooltip.prototype.tip = function () {\n      if (!this.$tip) {\n        this.$tip = $(this.options.template)\n        if (this.$tip.length != 1) {\n          throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')\n        }\n      }\n      return this.$tip\n    }\n  \n    Tooltip.prototype.arrow = function () {\n      return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))\n    }\n  \n    Tooltip.prototype.enable = function () {\n      this.enabled = true\n    }\n  \n    Tooltip.prototype.disable = function () {\n      this.enabled = false\n    }\n  \n    Tooltip.prototype.toggleEnabled = function () {","sourceCodeStart":1672,"sourceCodeEnd":1708,"githubUrl":"https://github.com/dotnet/AspNetCore.Docs/blob/c67a80103a1a74db20784debd919c7fdda96c510/aspnetcore/mvc/controllers/testing/samples/3.x/TestingControllersSample/src/TestingControllersSample/wwwroot/js/bootstrap.js#L1672-L1708","documentation":"Identical guard to error 0 in the 3.x sample copy of bootstrap.js: Tooltip.prototype.tip() requires the `template` option to yield exactly one top-level element via $(). `${this.type}` is \"tooltip\" or \"popover\".","triggerScenarios":"Passing a template with 0 or 2+ top-level nodes, a CSS selector instead of HTML, or an empty string to .tooltip({template})/.popover({template}) in the 3.x sample app.","commonSituations":"Customizing tooltip markup; cross-version template copy; bundler string corruption.","solutions":["Use a single rooted HTML element string for template.","Don't pass selectors as templates.","Drop the template option to fall back to Bootstrap's default."],"exampleFix":"// before\n$('#el').tooltip({ template: '' });\n// after\n$('#el').tooltip({ template: '<div class=\"tooltip\" role=\"tooltip\"><div class=\"tooltip-inner\"></div></div>' });","handlingStrategy":"validation","validationCode":"function isValidTooltipTemplate(tpl) {\n  if (typeof tpl !== 'string' || tpl.trim() === '') return false;\n  var nodes = $(tpl);\n  return nodes.length === 1 && nodes[0].nodeType === 1;\n}\nif (options.template && !isValidTooltipTemplate(options.template)) {\n  console.warn('Invalid tooltip template; using default');\n  delete options.template;\n}\n$('#el').tooltip(options);","typeGuard":"function isSingleElementTemplate(tpl) { return typeof tpl === 'string' && $(tpl).length === 1; }","tryCatchPattern":"try {\n  $('#el').tooltip({ template: customTpl });\n} catch (e) {\n  if (/template.*1 top-level element/.test(e.message)) {\n    $('#el').tooltip({});\n  } else { throw e; }\n}","preventionTips":["Wrap templates in a single root element.","Never use selectors as templates.","Smoke-test custom templates at build time."],"tags":["bootstrap","tooltip","dom","template","configuration"],"backgroundTag":null,"analyzedSha":"c67a80103a1a74db20784debd919c7fdda96c510","analyzedAt":"2026-08-13T17:46:11.763Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}