Skip to content

Is there any way to call from javascript? #135

Answered by ViRuSTriNiTy
drma-tech asked this question in Q&A
Discussion options

You must be logged in to vote

@chrissainty Exactly what I have done and it works pretty nicely. Here is my solution, perhaps it can serve as a template for other users:

JavascriptToastBridge.razor

@implements IDisposable

@inject IJSRuntime JSRuntime
@inject IToastService ToastService 

@code
{
    private DotNetObjectReference<JavascriptToastBridge> dotNetObjRef;
    private bool disposeCalled;

    protected override void OnInitialized()
    {
        base.OnInitialized();
        
        dotNetObjRef = DotNetObjectReference.Create(this);
    }

    public async void Dispose()
    {
        GC.SuppressFinalize(this);

        if (!disposeCalled)
        {
            await JSRuntime.InvokeVoidAsync("JavascriptToast…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by chrissainty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Question Question about this project Resolved: Answered The question raised by the author has been answered
3 participants
Converted from issue

This discussion was converted from issue #107 on October 08, 2021 13:57.