How to add text (in runtime) to the adminUI navigation shortcut


#1

How can i modify caption navigation shortcut in runtime? Needed add some text to it and some time change it in some period (few minutes for example) reloading only this menu or shortcut.


#2

You can use a DOM query to search for all navigation shortcuts user currently see on the left panel

var menuNodes = Ext.query('.ub-left-panel .ub_tree_text')
```
After this iterate over node collection and modify captions you interested on

```
menuNodes.forEach( function(elm) {
  if (elm.innerText.startsWith('Користувачі')) { 
    elm.innerText = 'Користувічі (10)' 
  } 
})
```

If you need periodically call a function - do it via [setInterval](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval)

To inject your script into existed application put it inside a `initModel.js` of your model `public` folder

#3

I change caption, but when i click on this menu item it return to original text. How can i avoid this and change it by timer or some else triger?


#4

Yes, as notified above:


#5

Sorry, i write alittle incorrect. I insert this code in initmodel.js use setInreval, but when i click on menu item - i get old text (this text will be changed when time is come).
But this looks bad. If i set small interval - this is too big load on server and client, if i set normal or big interval - user must wait random time (for user this time is random) for update and see new info. Some time this time is too big.