-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am trying to create a text editor which operates on contenteditable div. As it requires some events cancelled based on certain keystrokes etc, I cannot use Blazor. So instead I am using JavaScript that invokes Blazor functions as necessary.
The guidance given on the official documentation does not properly create this scenario. Every example given on that page requires a call to the JavaScript function to pass dotNetHelper
and that dotNetHelper
instance is used to invoke method on the Blazor component.
This is the reference doc https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-dotnet-from-javascript?view=aspnetcore-6.0#class-instance-examples
It does not help if JavaScript needs to trigger an event independently. The documentation does not cover the scenario at all.
It seems that there is no way for JavaScript to cleanly invoke a component's function (maintaining a static dictionary of {component id, dotNetHelper} comes to mind, but it sounds messy.
Expected Behavior
A clear example of .net functions being triggered independently from JavaScript, if it is possible at all.
.NET Version
6.0.5