updateMenuExtensions()

Forcedly updates the top-right Scrivito menu.

With Scrivito.extendMenu, custom menu items may depend on an external service, which requires asynchronous communication.

Scrivito automatically updates the top-right menu on every content-related change, however, other asynchronous changes are not automatically reflected. In such advanced cases, Scrivito.updateMenuExtensions comes to the rescue.

Whenever a state change in your application affects a menu extension, call Scrivito.updateMenuExtensions. This forces the menu extensions to be re-evaluated. Afterwards, the menu will be in sync with the application’s current state.

Examples

Conditionally show an “openStatistics” menu item. The menu item must only show up if the HTTP API listening at “/api/adminToken” responds with an OK status:

Enable a “betaFeature” item only after the user executed the toggleBeta() command in the browser console: