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
bind-value-oninput throws #5521
Comments
We already support binding to the As for the throttling, that's an interesting question. For the short term at least I'd not want to complicate the event system with baking that in, at least not until there are more requests for it and we see the scenarios more broadly. You can implement throttling yourself either by literally writing the code that throttles inside your event handler, or by using a library like Rx that has a built-in implementation. I know it's tricky to prevent redundant renders with this approach so we can keep considering it in the future if more people are requesting it often. |
@SteveSandersonMS unfortunately your solution doesn't work. This code
throws exception visible in console:
I can change oninput to onchange |
Thanks. We'll have to review that. |
It looks that bind-value-onchange is the only one which works. I have checked bind-value-onclick, bind-value-onkeypress, and a few more and I always see exceptions. |
For anyone wondering, since as of right now (at least for me) with version 0.4.0 bind-value-oninput still throws I found another method to update the bound value.
The oninput function being the important part. |
That does work, great find. Is there any explanation for that part in documentation? |
@ransagy |
Ah, I knew i had to be missing something. Thanks for the heads up. Here's hoping Blazor will get around to doing it on its own relatively quickly. |
Blazor does handle the oninput event, but it was marshalled as a regular UIEventArgs. This meant that we didn't have access to the new value of the input element from our oninput handler. Fixes #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
Thanks @L3tum, great workaround for now |
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
- Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
* Marshal oninput events as UIChangeEventArgs - Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
* Marshal oninput events as UIChangeEventArgs - Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This means that we cannot access the new value of the input element from inside our oninput handler Addresses #821
I have just retested this bug in Blazor 0.7 and this code now works as expected: <input bind-value-oninput="@FieldValue" />
<p>@FieldValue</p>
@functions{
string FieldValue { get; set; }
} Unfortunately |
Where can I read (in the docs) about https://blazor.net/docs/components/index.html#data-binding only knows about |
@springy76 it is probably not documented. I have just added this issue aspnet/Blazor.Docs#368. |
Thanks for contacting us. |
@mkArtakMSFT The problem with bind-value-oninput was fixed but if I want to use other events, for example bind-value-onkeydown, bind-value-onkeyup I'm still getting an exception. Currently I have the newest ASP.NET Core 3.0 Preview 4 and I see this in the browser's console:
|
@Andrzej-W Closing as we don't think there is anything left to do here. |
https://github.com/aspnet/Blazor/issues/1235#issuecomment-489328205
In the below code, the expectation is as and when I edit the div content I need to update the model so that I can then later save it back.
|
Hello @PirasannaRavi ... Please open product feedback over in the aspnet/AspNetCore issues. |
Sure @guardrex. |
bind-value-oninput does not throw an exception but it also does not update the variable as of version 3.0.0-preview6.19307.2
This results in the following in the console window |
@mvr-devs Try this ... <div class="search-bar">
<input @oninput="@PreformSearch" placeholder="search for customers or tickets" />
</div>
@code {
private void PreformSearch(UIChangeEventArgs e)
{
Console.WriteLine($"Something tells me you are trying to search for '{e.Value}' ...");
}
} The events are covered here 👉 https://docs.microsoft.com/aspnet/core/blazor/components?view=aspnetcore-3.0#event-handling ... BUT ... I'm working on a nicer presentation and showing all of them here 👉 dotnet/AspNetCore.Docs#12929 ... and the link you see in that new coverage (https://github.com/aspnet/AspNetCore/blob/master/src/Components/Components/src/UIEventArgs.cs) will get you to the reference source, so you can really 👀 the details and API notes. |
Perfect !! Thanks so much !! |
Currently when we use
<input bind="@myVariable" />
variable is updated when input field looses focus (onchange event is called). Popular requirement in many applications is to implement incremental search. To do this we need:I believe that throttling can be useful for other events also, for example mouse move, mouse wheel scrolling, etc.
The text was updated successfully, but these errors were encountered: