I've been trying to figure out a way to dynamically set the title of a page and keep the title on refresh. I took a look at this forum post where they suggest using an onStartup script to set the page title. The problem is once the page is refreshed the title reverts back to what the name is in the page configuration
If you have a shared docked view, you could add two custom properties for current title and desired title. Bind the current title to page.props.title. Add change scripts to both that check for matching strings. Copy from desired to current when not equal.
Everywhere that you are currently setting page.props.title, send a message to the docked view to change view.custom.desiredTitle instead.
FWIW, this behavior could be leveraged to make a reliable refresh event detector, which is highly desired by some users.
here’s an example comparison/what I came up with (on a RadioGroup custom prop) to coordinate a docked radio button with a urlParam referenced by main view (binding json)
if not hasattr(self.page.props.urlParams, 'Type_ID') or self.page.props.urlParams.get('Type_ID') != self.props.value:
self.page.props.urlParams.Type_ID = self.props.value
This won't write null to the urlParam when a radio button with value of null is selected... I’m sure the reason is obvious but I’m sick of staring at it so I added a change script on radio.props.value for that edge case.
@Jacob_Clark - saw you hearted this - I found the previous example could introduce a race condition when switching from a non-null value to a null value, so I’ve updated it.