blazorbootstrap-starter-templates icon indicating copy to clipboard operation
blazorbootstrap-starter-templates copied to clipboard

Could not find window.blazorBootsrap.collapse.initialize ('blazorBootsrap' was undefined)

Open alexnayberg opened this issue 1 year ago • 4 comments

Hello, I just installed BlazorBootstrap on a Blazor Web App project on .Net 8. I am having a problem with a component that's using Accordion. This is the error I am seeing:

Error: Microsoft.JSInterop.JSException: Could not find 'window.blazorBootstrap.collapse.initialize' ('blazorBootstrap' was undefined). Error: Could not find 'window.blazorBootstrap.collapse.initialize' ('blazorBootstrap' was undefined). at https://localhost:7281/_framework/blazor.web.js:1:734 at Array.forEach () at l.findFunction (https://localhost:7281/_framework/blazor.web.js:1:702) at b (https://localhost:7281/_framework/blazor.web.js:1:5445) at https://localhost:7281/_framework/blazor.web.js:1:3238 at new Promise () at y.beginInvokeJSFromDotNet (https://localhost:7281/_framework/blazor.web.js:1:3201) at fn._invokeClientMethod (https://localhost:7281/_framework/blazor.web.js:1:62541) at fn._processIncomingData (https://localhost:7281/_framework/blazor.web.js:1:60016) at connection.onreceive (https://localhost:7281/_framework/blazor.web.js:1:53657) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at BlazorBootstrap.Collapse.<OnInitializedAsync>b__4_0() at BlazorBootstrap.BlazorBootstrapComponentBase.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

I tried it in both Server and WebAssembly projects, and got the error in both. I followed your instructions to make sure I didn't miss anything: Getting Started.

alexnayberg avatar Dec 31 '23 04:12 alexnayberg

@alexnayberg, thank you for trying BlazorBootstrap. Please share a sample code or GitHub repo to reproduce the issue, rather than assuming. This will help us to better understand the issue.

gvreddy04 avatar Dec 31 '23 18:12 gvreddy04

@alexnayberg Please test your changes in the below starter project and let me know.

Starter Project: https://github.com/vikramlearning/blazorbootstrap-starter-templates/tree/master/src/BlazorBootstrap.Templates.Starter/Net8.BlazorAutoGlobal

gvreddy04 avatar Dec 31 '23 18:12 gvreddy04

Thank you for responding! I just took your boilerplate code from your demo website and ran it locally: @page "/test-client" @rendermode InteractiveWebAssembly <Accordion> <AccordionItem> <TitleTemplate> <Icon Name="IconName.HouseFill" Class="me-1" /> Accordion Item #1 </TitleTemplate> <Content> <b>This is the first item's accordion body.</b> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. </Content> </AccordionItem> <AccordionItem> <TitleTemplate> <Icon Name="IconName.PersonFill" Class="me-1" /> Accordion Item #2 </TitleTemplate> <Content> <b>This is the second item's accordion body.</b> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. </Content> </AccordionItem> <AccordionItem> <TitleTemplate> <Icon Name="IconName.PhoneFill" Class="me-1" /> Accordion Item #3 </TitleTemplate> <Content> <b>This is the third item's accordion body.</b> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. </Content> </AccordionItem> </Accordion>

And I did it on both client (above) and server projects: @page "/test-server" @rendermode InteractiveServer <Accordion> <AccordionItem> <TitleTemplate> <Icon Name="IconName.HouseFill" Class="me-1" /> Accordion Item #1 </TitleTemplate> <Content> <b>This is the first item's accordion body.</b> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. </Content> </AccordionItem> <AccordionItem> <TitleTemplate> <Icon Name="IconName.PersonFill" Class="me-1" /> Accordion Item #2 </TitleTemplate> <Content> <b>This is the second item's accordion body.</b> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. </Content> </AccordionItem> <AccordionItem> <TitleTemplate> <Icon Name="IconName.PhoneFill" Class="me-1" /> Accordion Item #3 </TitleTemplate> <Content> <b>This is the third item's accordion body.</b> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. </Content> </AccordionItem> </Accordion> I also upgraded the nuger package to the latest version. Same behaviour before and after the upgrade though.

I really like your framework, I've used it on .MET6 and .NET7 projects and it's been working great. I just want to keep using it with .NET8 so I can take advantages of all the new stuff Blazor has to offer. Thanks again for follow up.

alexnayberg avatar Jan 02 '24 01:01 alexnayberg

@alexnayberg Pleaseshare the below information:

  • BlazorBootstrap Version:
  • Blazor WebAssembly / Server:
  • Interactive RenderMode:
  • Render Location:
  • .NET Version:

Also share a GitHub repo to reproduce your issue. I'll a take look and let you know what was missing.

gvreddy04 avatar Jan 02 '24 04:01 gvreddy04

We are also seeing this same issue on a newer .NET 9 Blazor Hybrid project. Here is the requested info from the previous post (that was not followed up on).

BlazorBootstrap Version: 3.3.1 Blazor WebAssembly / Server: Server Interactive RenderMode: InteractiveServer Render Location: MainLayout.razor .NET Version: .NET 9

This package looks promising, but first go at it produces this same error on the latest .NET 9 fresh project standup.

Any help would be very appreciated. Thank you!

AdamBauerle avatar Apr 24 '25 15:04 AdamBauerle