chanan/BlazorStrap

Issue: Could not find 'blazorStrap.AddEvent' ('blazorStrap' was undefined).

clebron949 opened this issue · 4 comments

Hi!

Whenever I run the dll or the executable from my application I get "Could not find 'blazorStrap.AddEvent' ('blazorStrap' was undefined)." However, if I run the application in the debugger it runs fine.

Please help. It will suck if I need to rewrite my app because of this. I have no idea what is going on.

Here is the error when I run from the dll or executable.

warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: Could not find 'blazorStrap.AddEvent' ('blazorStrap' was undefined).
@https://localhost:5001/_framework/blazor.server.js:1:506
forEach@[native code]
findFunction@https://localhost:5001/_framework/blazor.server.js:1:472
@https://localhost:5001/_framework/blazor.server.js:1:3495
Promise@[native code]
beginInvokeJSFromDotNet@https://localhost:5001/_framework/blazor.server.js:1:3486
forEach@[native code]
_invokeClientMethod@https://localhost:5001/_framework/blazor.server.js:1:72079
_processIncomingData@https://localhost:5001/_framework/blazor.server.js:1:70133
@https://localhost:5001/_framework/blazor.server.js:1:48860
Microsoft.JSInterop.JSException: Could not find 'blazorStrap.AddEvent' ('blazorStrap' was undefined).
@https://localhost:5001/_framework/blazor.server.js:1:506
forEach@[native code]
findFunction@https://localhost:5001/_framework/blazor.server.js:1:472
@https://localhost:5001/_framework/blazor.server.js:1:3495
Promise@[native code]
beginInvokeJSFromDotNet@https://localhost:5001/_framework/blazor.server.js:1:3486
forEach@[native code]
_invokeClientMethod@https://localhost:5001/_framework/blazor.server.js:1:72079
_processIncomingData@https://localhost:5001/_framework/blazor.server.js:1:70133
@https://localhost:5001/_framework/blazor.server.js:1:48860
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, CancellationToken cancellationToken, Object[] args)
at BlazorStrap.Shared.Components.Common.BSPaginationBase1.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit '8g5aSCEnrc7aT05GcMvTYbsyv7IC0t9oBN1LDfzSjQg'. Microsoft.JSInterop.JSException: Could not find 'blazorStrap.AddEvent' ('blazorStrap' was undefined). @https://localhost:5001/_framework/blazor.server.js:1:506 forEach@[native code] findFunction@https://localhost:5001/_framework/blazor.server.js:1:472 @https://localhost:5001/_framework/blazor.server.js:1:3495 Promise@[native code] beginInvokeJSFromDotNet@https://localhost:5001/_framework/blazor.server.js:1:3486 forEach@[native code] _invokeClientMethod@https://localhost:5001/_framework/blazor.server.js:1:72079 _processIncomingData@https://localhost:5001/_framework/blazor.server.js:1:70133 @https://localhost:5001/_framework/blazor.server.js:1:48860 at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, CancellationToken cancellationToken, Object[] args) at BlazorStrap.Shared.Components.Common.BSPaginationBase1.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

seams like your just missing
"the At the end of the add

<script src="_content/BlazorStrap/popper.min.js"></script> <script src="_content/BlazorStrap/blazorstrap.js"> in your _host.cshtml" please verify its not 404ing in your live project if it's there

Hi @jbomhold3,

Thank you so much for responding.

I don't think I'm missing " in the script. Here is how I'm referencing it.

Screenshot 2023-02-16 at 4 43 39 PM

However, I'm getting a 404 error message in popper.min.js and blazorstrap.js

image

This thing was working fine not too long ago. Any suggestions?

Looks like you have another library as well having trouble with content. Can you post your csproj and startup and make sure you include static files

I finally figure out my issue. For some strange reason, the app was not loading the static web files. All I had to do was include this line in my Program.cs

StaticWebAssetsLoader.UseStaticWebAssets(app.Environment, app.Configuration);

See this article for reference:
https://dev.to/j_sakamoto/how-to-deal-with-the-http-404-content-foo-bar-css-not-found-when-using-razor-component-package-on-asp-net-core-blazor-app-aai

Thank you for your time!