Skip to content

Change the Plugin Live

update changes how a plugin looks, or which sections it shows, without reloading it. For example, to follow your site’s dark-mode switch:

SportNinja.push(['update', { theme: { mode: 'dark', primary: '#1C7ED6' } }]);

SportNinja.push(['update', target, changes]), or SportNinja.push(['update', changes]) for every plugin on the page.

Argument Required What it is
target No The selector or element the plugin was mounted on. Leave it out to update every plugin on the page.
changes Yes An object with at least one of theme, display or sections.
SportNinja.push(['update', '#standings', { display: { hideHeader: true } }]); // one plugin
SportNinja.push(['update', { theme: { mode: 'dark' } }]); // every plugin
  • Each option replaces the plugin’s own. Send the full theme you want for that plugin, not just the key that changed. The page’s theme and display from init still sit underneath.
  • Only the look and sections change. render, id, initialSection and key are fixed once the plugin is shown; anything else is ignored with a console warning. To change those, remove the plugin and display it again.
  • Plain data only. Values can’t be functions or DOM objects.

Example: keep your accent colour and switch the mode.

const theme = { primary: '#1C7ED6' };
function setDark(isDark) {
SportNinja.push(['update', { theme: { ...theme, mode: isDark ? 'dark' : 'light' } }]);
}