Persistent Page Titles in Perspective

Hello guys,

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

Interesting.

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.

1 Like

Thanks, this might be useful to more reliably retrieve (unchanged) values of parameters after a refresh and re-inject them into urlParams

I wish your pageVarMap() function was a built-in!

1 Like

Well, I don't, as you might suspect. The most useful functions provide the most motivation to crack the anti-3rd-party-module foolishness.

4 Likes

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)

binding
{
  "type": "expr-struct",
  "config": {
    "struct": {
      "radio": "{this.props.value}",
      "url": "{page.props.urlParams.Type_ID}"
    },
    "waitOnAll": true
  }
}
change script
	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.

1 Like

@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.