valincius / BlazorScheduler

Scheduler built with Blazor

Home Page:https://valincius.github.io/BlazorScheduler/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'BlazorScheduler' was undefined

rgry opened this issue · comments

commented

Describe the bug
Properly not a bug, just me not understanding how to get started.
Your project solution work fine. But when I do a new project and follow the few step from the readme file the blazor app is not running proberly. It compiles without errors. Only runtime error
I did not copy the scripts.js to a folder? is your package doing that for me?

To Reproduce
New blazor webasm project.
steps from readme
(and I did Add <script src="_content/BlazorScheduler/js/scripts.js"></script> to the body

Expected behavior
Was not expecting "crash" on page

Screenshots
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Could not find 'BlazorScheduler.attachSchedulerMouseEventsHandler' ('BlazorScheduler' was undefined).
Error: Could not find 'BlazorScheduler.attachSchedulerMouseEventsHandler' ('BlazorScheduler' was undefined).
at https://localhost:4201/_framework/blazor.webassembly.js:1:328
at Array.forEach ()
at a.findFunction (https://localhost:4201/_framework/blazor.webassembly.js:1:296)
at _ (https://localhost:4201/_framework/blazor.webassembly.js:1:2437)
at https://localhost:4201/_framework/blazor.webassembly.js:1:3325
at new Promise ()
at Object.beginInvokeJSFromDotNet (https://localhost:4201/_framework/blazor.webassembly.js:1:3306)
at Object.St [as invokeJSFromDotNet] (https://localhost:4201/_framework/blazor.webassembly.js:1:59853)
at _mono_wasm_invoke_js_blazor (https://localhost:4201/_framework/dotnet.6.0.5.7ue9mewvww.js:1:195300)
at wasm://wasm/00971e46:wasm-function[219]:0x1a490
Microsoft.JSInterop.JSException: Could not find 'BlazorScheduler.attachSchedulerMouseEventsHandler' ('BlazorScheduler' was undefined).
Error: Could not find 'BlazorScheduler.attachSchedulerMouseEventsHandler' ('BlazorScheduler' was undefined).
at https://localhost:4201/_framework/blazor.webassembly.js:1:328
at Array.forEach ()
at a.findFunction (https://localhost:4201/_framework/blazor.webassembly.js:1:296)
at _ (https://localhost:4201/_framework/blazor.webassembly.js:1:2437)
at https://localhost:4201/_framework/blazor.webassembly.js:1:3325
at new Promise ()
at Object.beginInvokeJSFromDotNet (https://localhost:4201/_framework/blazor.webassembly.js:1:3306)
at Object.St [as invokeJSFromDotNet] (https://localhost:4201/_framework/blazor.webassembly.js:1:59853)
at _mono_wasm_invoke_js_blazor (https://localhost:4201/_framework/dotnet.6.0.5.7ue9mewvww.js:1:195300)
at wasm://wasm/00971e46:wasm-function[219]:0x1a490
at Microsoft.JSInterop.JSRuntime.d__16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at BlazorScheduler.Scheduler.AttachMouseHandler() in C:\Users\rune\Documents\Visual Studio 2022\BlazorScheduler-main\BlazorScheduler\Components\Scheduler.razor.cs:line 120
at BlazorScheduler.Scheduler.OnAfterRenderAsync(Boolean firstRender) in C:\Users\rune\Documents\Visual Studio 2022\BlazorScheduler-main\BlazorScheduler\Components\Scheduler.razor.cs:line 82
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Desktop (please complete the following information):

  • OS: Win10x64
  • Browser Edge 101
commented

Sounds like you've got it setup properly. Have you tried clearing your cache ?

commented

Thank you Valincius, that did the trick!
How to you handle cache in your projects? How to tell the browser, that a new/updated project is loaded?

kind regards
Rune

commented

I've only deployed a single internal blazor server project, there I would just have the consumers clear the cache themselves.
Usually people will add a query parameter with a version number, then increment that whenever there's changes.
So you'd do something like:
<script src="_content/BlazorScheduler/js/scripts.js?v=1.0.0"></script>
Then increment this whenever you update the package.

The version number doesn't matter, it doesn't even have to be a version number, just some text so that the browser knows to fetch a new version. There may be something out there that can handle this sort of thing for you

commented

Thanks :-)