-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation for Blazor custom event args feature #21763
Comments
@mkArtakMSFT ...
|
@mkArtakMSFT Update:
Actually, I think I misunderstood your remark on ...
It looks like you were saying that DR's example ('real world' for a custom paste) is the 'attached to DOM-type event'. I think we're good here. I'll ping u on Monday when that PR is ready for review. |
I followed the writeup for checking custom event args feature in Blazor - "Register custom event handlers in DOM and handle those in .NET". Environment:.NET 6.0 RC We have few LitELement custom elements with custom events triggered. I tried to follow the documentation for as mentioned here. What I did?
Now, whenever the custom event ("closed") is fired by custom-control, my event handler is not getting called. Anything I am missing, do you have a working sample? |
@msbasanth ... We don't work off of closed issues/PRs, and for product unit visibility to report a potential problem with a preview feature, open an issue on their repo at ... https://github.com/dotnet/aspnetcore/issues If you find that the preview docs are missing something or have incorrect guidance after working with them, open a new issue from the bottom of the topic using the This page feedback button and form ... |
This is a request to add documentation for Blazor Custom Event arguments feature which is (going to be) introduced as part of 6.0-preview2 release.
The feature enables the following two scenarios:
Draft writeup for the first scenario can be found from the 6.0-preview2 announcement blog post.
For the second scenario, please use the draft from below:
///////////////////////////////////////////////////////////////
Blazor's support for custom events is now expanded to also support custom event arguments.
This allows passing arbitrary data to .NET event handlers with custom events.
Follow the steps below to define a custom event with custom event argument(s):
** on the JavaScript side
Note, that the above call is done in a javascript and can be called only once (per each event).
** on the .NET side
3. define a class for the event args
EventHandler
attribute annotation for your custom event:Now, whenever the custom event is fired on the DOM, your event handler will be called with the data passed from the Javascript.
Note, that if you're trying to fire a custom event, you'll need to make sure that it has to have
bubbles: true
, as otherwise it won't get to the Blazor handler to process it.The text was updated successfully, but these errors were encountered: