Semantic-Org/Semantic-UI · info

No maximum rating specified. Cannot generate HTML automatica

Error message

No maximum rating specified. Cannot generate HTML automatically

What it means

NOTE: this message is registered in settings.error but is never invoked anywhere in rating.js — no module.error(error.noMaximum) call exists. setup.layout() reads get.maxRating() (defaulting to settings.maxRating = 4) and renders that many icons via templates.icon() with no guard. The string is effectively dead documentation; it would have warned that auto-generating star HTML requires a maxRating.

Source

Thrown at src/definitions/modules/rating.js:472

  namespace     : 'rating',

  slent         : false,
  debug         : false,
  verbose       : false,
  performance   : true,

  initialRating : 0,
  interactive   : true,
  maxRating     : 4,
  clearable     : 'auto',

  fireOnInit    : false,

  onRate        : function(rating){},

  error         : {
    method    : 'The method you called is not defined',
    noMaximum : 'No maximum rating specified. Cannot generate HTML automatically'
  },


  metadata: {
    rating    : 'rating',
    maxRating : 'maxRating'
  },

  className : {
    active   : 'active',
    disabled : 'disabled',
    selected : 'selected',
    loading  : 'loading'
  },

  selector  : {
    icon : '.icon'
  },

View on GitHub (pinned to 597843ab84)

Solutions

  1. Provide a maxRating: data-max-rating="5" or { maxRating: 5 }
  2. Or include the icon markup manually: <div class="ui rating"><i class="icon"></i> ...</div>

Example fix

<!-- before -->
<div class="ui rating"></div>
<!-- after -->
<div class="ui rating" data-max-rating="5"></div>
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a maxRating exists before relying on auto-generated icons.
function ratingHasMax($el, settings) {
  settings = settings || {};
  var n = settings.maxRating || $el.data('maxRating') || $el.attr('data-max-rating');
  return Number(n) > 0;
}
if (ratingHasMax($('.ui.rating'))) {
  $('.ui.rating').rating();
} else {
  $('.ui.rating').rating({ maxRating: 5 }); // supply a default
}

Type guard

function hasMaxRating(settings) {
  return !!settings && Number.isFinite(settings.maxRating) && settings.maxRating > 0;
}

Prevention

When it happens

Trigger: Not actually triggered at runtime. The scenario it describes: a .ui.rating element with no <i class="icon"> children and no maxRating (data-max-rating / settings.maxRating) — setup.layout() would call templates.icon(maxRating) with a falsy maxRating, producing zero stars. You get no stars, but also no error.

Common situations: <div class="ui rating"></div> with no icons and no maxRating — the symptom is an empty rating, not a logged error.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/664165fb285f0a07. Report an issue: GitHub.