Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Persist Bootstrap theming through blazor navigations

$
0
0

I'm making a blazor server app, and storing the theme in the client's browser LocalStorage. This means that when the server side rendering happens the clientss theme is not available to the server.

I want to persist the client's theme throughout the entire blazor app

I've tried handling all of it using javascript, but when you navigate in blazor, the document itself doesn't reload, so my javascript changes to the DOM don't persist through navigations.

I've tried creating and registering a scoped ThemeService, and bind the data-bs-theme attribute to the ThemeService.Theme Property and gave it a default value. Then i added a component that updates the ThemeService.Theme on the initial OnAfterRenderAsync. But the ThemeService's lifetime/scope appears to reset every time i navigate pages, so it just returns to the assigned default...


UPDATE: I've figured out that the scoped service does in fact have the same lifetime as the circuit, but the circuit dies when NavigationManager.NavigateTo() gets called in OnInitialized()


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>