-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Document EventCallback #11243
Document EventCallback #11243
Comments
Cross-ref: https://github.com/aspnet/Blazor/issues/1355 BindingParentComponent.cshtml: @page "/BindingParentComponent"
<h1>Parent Component</h1>
<p>ParentYear: @ParentYear</p>
<BindingChildComponent Year="@ParentYear" YearChanged="@ChildFiredEvent" />
<button class="btn btn-primary" onclick="@ChangeYearFromParent">
Change Year to 1986 from the Parent component
</button>
@functions {
[Parameter]
private int ParentYear { get; set; } = 1978;
void ChangeYearFromParent()
{
ParentYear = 1986;
}
void ChildFiredEvent(int year)
{
ParentYear = year;
StateHasChanged();
}
} BindingChildComponent.cshtml: <h2>Child Component</h2>
<p>Year: @Year</p>
<button class="btn btn-primary" onclick="@ChangeYearFromChild">
Change Year to 2027 from the Child component
</button>
@functions {
[Parameter]
private int Year { get; set; }
[Parameter]
private Action<int> YearChanged { get; set; }
void ChangeYearFromChild()
{
Year = 2027;
YearChanged(Year);
}
} Works but is at odds with @rpc-scandinavia Let's put this on hold for a bit. I need to consult with engineering, and they're 🏃😅 right now. I'll get up with them later in the week. btw ...
That's just for demonstration purposes to show the value from both the parent and the child. It isn't really the focus of the scenario. |
@guardrex So perhaps it will work in 3.0 with the "EventCallback". |
Management will triage this and provide guidance. I have a feel'in that we'll hit it for 3.0 ... but we'll see how they want to play it later. |
Cross-ref: EventCallback: Updates to Event Handling and Binding No reason to delay this work ... I'll get on it very soon! |
From @RichiCoder1 on #11682 ... Examples on how to affect the Layout rendering from Body component
I'll test |
Awesome! Thanks |
Under "Component parameters" (Data binding), I don't see an example on how the parent component get its variable updated when it is changed IN the child component. The example shows the change being made in the parent component, all the child component do is showing its own variable, and that works without "bind".
Dokumentinformasjon
⚠ Ikke rediger denne delen. Den kreves for koblingen docs.microsoft.com ➟ GitHub-problem.
The text was updated successfully, but these errors were encountered: