Skip to content

invoke javascript arrow function from IJSRuntime #19484

Closed
@zachneu

Description

@zachneu

When creating class library with razor/blazor components and the components need to execute some JavaScript code, you need to add a reference to a JavaScript file in index.html with the functions you need (or in some script tag in the html file). this will require you to add at least one JavaScript code before you can invoke any JavaScript file.

To solve this problem it would be nice if the IJSRuntime support to call arrow functions.

Example of this could be:
SRuntime.InvokeVoidAsync("() => alert('testing'))();");

With this support I can also run an arrow function to dynamically load css or JavaScript files if they are needed by the component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onequestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions