Does not show after calling JSRuntime.Invoke

3 posts, 1 answers
  1. Jonathan
    Jonathan avatar
    116 posts
    Member since:
    Jan 2014

    Posted 11 May Link to this post

    Hi..

    I have the following code.  

    After JSRuntime is called the AnimationContainer does not show. I get a screen flicker.

    Any idea how I can show the Animation Container after opening (downloading a file)

    thanks again!

     

            await JSRuntime.InvokeAsync<object>("open", URI, "_blank");

                     
            await AnimationContainer.ShowAsync();
            StateHasChanged();

            await Task.Delay(5000);

            await AnimationContainer.HideAsync();
            StateHasChanged();

  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    5458 posts

    Posted 11 May Link to this post

    Hello Jonathan,

    The provided code snippet throws an error in the window.open call, which breaks the entire app. I am attaching a short video that demonstrates this. I strongly advise that you monitor the browser console to ensure there are no errors. Blazor cannot take circular JS object references, and the window object returned from window.open has a circular reference - its .parent field points to the current window instance.

    A workaround for that can be defining you own function that does not create a circular reference because it will never serialize a return type back to Blazor. For your convenience, I am attaching a sample of this.

     

    Regards,
    Marin Bratanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Jonathan
    Jonathan avatar
    116 posts
    Member since:
    Jan 2014

    Posted 11 May in reply to Marin Bratanov Link to this post

    Awesome!.. thx again
Back to Top