Is this possible to integrate jQuery UI components inside Blazor application?

后端 未结 1 504
有刺的猬
有刺的猬 2021-01-21 01:27

I want to integrate the jQuery UI component within the Blazor client-side application. The Spinner component looks better in jQuery UI. is this possible? how to integrate it?

1条回答
  •  [愿得一人]
    2021-01-21 01:59

    This is the way to create a wrapper for a JQuery or JS control:

    1.- Enclose JS behavior in functions:

    
    

    Don't forget to include other JS/JQuery libraries.

    2.- Initialize control from blazor:

    @code {
    
        protected async override Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                await JsRuntime.InvokeAsync("myWrapperKSUIfunctions.initialize");
            }
        }
    
    
    

    3.- Call JS function from blazor:

      
    
    @code {
    
        ...
        protected async Task JustCall(string f)
        {
            wait JsRuntime.InvokeAsync($"myWrapperKSUIfunctions.{f}"); 
        }
    
    
    
    

    Check it out at blazorfiddle.

    Also, take a look to MatBlazor controls.

    0 讨论(0)
    提交回复
    热议问题