Call JavaScript From Blazor Web Assembly

Поділитися
Вставка
  • Опубліковано 21 жов 2024

КОМЕНТАРІ • 11

  • @miles6875
    @miles6875 3 місяці тому

    Great presentation

  • @RafaelGamerAll
    @RafaelGamerAll 3 місяці тому

    Nice, but why all js functions start with "window.", its necessary?

    • @scriptbytes
      @scriptbytes  3 місяці тому +1

      It attaches the function to the browser's window object, effectively making them global.

  • @davidpereira4026
    @davidpereira4026 5 місяців тому

    Which ide are you using to code?

  • @jesperkped
    @jesperkped 5 місяців тому

    Running dotnet 8.0.103
    Nomatter how much I try to add my javascript to my index.html it does not show up in my loaded page. Using Firefox and the developer tools I don't even see it trying to be loaded.
    For a while it worked without any problems but now 3 days where I did not touch the project it suddenly is not loaded.
    ...

    ...
    I tried to move it down to where the blazor.webassembly.js script is loaded - and no changes.
    It is like that line is filtered out by the backend.

    • @scriptbytes
      @scriptbytes  5 місяців тому +1

      We’ve got dotnet 8 apps running at work with js in them and haven’t had this issue, so I’m not sure what it might be.
      I hope you find a fix!

    • @stevenvillarreal8970
      @stevenvillarreal8970 3 місяці тому +1

      I found that sometimes having the line "@rendermode InteractiveServer" at the top of the page (in this case it would be JSDemo.razor) makes it so the page has interactive elements.

  • @SupriyaDeshmukh-nl8si
    @SupriyaDeshmukh-nl8si 3 місяці тому

    i dont have index.cshtml page. I just have app.razor

    • @scriptbytes
      @scriptbytes  2 місяці тому

      My demo is using blazor WASM. I assume yours is a server side app? I haven't done this with a server app, but I think as long as you put the js link in whichever file has the tag in it, I think it'll work.