jdtcn / BlazorDateRangePicker

A Blazor component for choosing date ranges and dates
MIT License
182 stars 35 forks source link

Binding event does not trigger #58

Closed Dylan-DutchAndBold closed 3 years ago

Dylan-DutchAndBold commented 3 years ago

Reading into the MS docs it seems that with two-way data binding I should be able to catch the triggering event instead of usingOnRangeSelect. However when I try @bind-StartDate:event="SomeHandlerFunction" nothing seems to happen.

https://docs.microsoft.com/en-us/aspnet/core/blazor/components/data-binding?view=aspnetcore-5.0#binding-with-component-parameters

jdtcn commented 3 years ago

Hi,

As far as I know, the purpose of @bind:event syntax is to select exact DOM event on which the binding occurs (for example oninput, onclick etc.). This syntax doesn't make sense in this case.

The binding you're looking for should look like this:

<DateRangePicker StartDateChanged="SomeHandlerFunction" />

@code {
    private void SomeHandlerFunction()
    {

    }
}
Dylan-DutchAndBold commented 3 years ago

Oh I see, so it's like telling on what Parameter (of type EventCallback) of that component to bind the change handler? I got that quite twisted then. Thanks a lot for the sample. It's clear now.

jdtcn commented 3 years ago

Yes exactly. The example from their docs is a bit misleading. But the tricky part is that we cannot use @bind-Property and PropertyChanged at the same time, because @bind- uses that PropertyChanged handler under the hood.