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' } }]);What You Pass
Section titled “What You Pass”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 pluginSportNinja.push(['update', { theme: { mode: 'dark' } }]); // every pluginGood to Know
Section titled “Good to Know”- Each option replaces the plugin’s own. Send the full
themeyou want for that plugin, not just the key that changed. The page’s theme and display frominitstill sit underneath. - Only the look and sections change.
render,id,initialSectionandkeyare 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' } }]);}