Run code after prerendered embedded Server component has been materialized in the browser #49389
-
This is about the Blazor architecture in the upcoming .NET 8: How do I execute code (client JavaScript) after a Server-rendered components that has been pre-rendered as part of a SSR:ed page get materialized in the browser?
So shouldn't there be an event for when the component has been materialized in the browser? On which this kind of logic can be safely executed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
When the components execute on the server they are gone by the time the HTML is transferred to the client. Executing a script in that case can be achieved by subscribing to "enhancedload" in the Blazor ecosystem or using a mutation observer to get notified when a given element appears on the page. If we are talking interactive components, they will trigger an OnAfterRender the moment they become interactive and render in that mode for the first time. |
Beta Was this translation helpful? Give feedback.
When the components execute on the server they are gone by the time the HTML is transferred to the client. Executing a script in that case can be achieved by subscribing to "enhancedload" in the Blazor ecosystem or using a mutation observer to get notified when a given element appears on the page.
If we are talking interactive components, they will trigger an OnAfterRender the moment they become interactive and render in that mode for the first time.