How does LiveView update the page title?

Through this post I know how to set the title when rendering a subpage, but it only work on the first visit: Page title via live view route that’s compatible with existing code in regular views?

However, it doesn’t fire when LiveView dynamically updates the page, so the page title will remain the same.

What is the solution? Can the LayoutView be built as a LiveView?

1 Like

Is it not the case that the page title is not a DOM subnode of the node where the liveview content is rendered?

You need something that can execute arbitrary JavaScript ie document.title = "dave".

Or am I totally wrong (just woke up).

1 Like

I guess the complexity is not setting the page title, but making sure you don‘t get into a case where multiple entities (live views in this case) try to concurrently modify the page title. This is a similar challenge to handling url params, which are also only allowed to be modified by a router mounted root live view. Therefore I guess it‘ll need some special treatment before it can work well. But until that‘s available you might be able to fake the functionality using the javascript hooks of phoenix live view.

2 Likes