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

Blazor JS Interop : Still calling function in @code block of prior razor page that was bound to window.resize

$
0
0

I have a problem that I do not know how to solve.

I am using a nuget package in a Blazor Webassembly project, which imports its own javascript library upon component initialization.

This library wires a function in the @code block to the window.onresize function which calls the function in the c# code block via the managed instance ...managedInstance.invokeMethodAsync

the problem I have found is that when I navigate to a different route / page this wired onresized is still calling the c# function in the code block of the page that is no longer rendered..

Also, when I return to the original razor page the function in the @code block is called twice, since i send the managed instance again on initialization to the javascript library.

how can Iuse@implements IDisposable

and

    public void Dispose()    {}

to stop the javascript function from calling my @code block?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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