aspnetcore: bind-value-oninput throws
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:
- binding which updates variable after every input field change
- throttling - this is necessary if we want to do incremental search on the server or we have a big collection to filter; we should be able to specify a delay in milliseconds and our variable should be updated only after user stops typing for the specified period of time
I believe that throttling can be useful for other events also, for example mouse move, mouse wheel scrolling, etc.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 21 (6 by maintainers)
Commits related to this issue
- Marshal oninput events as UIChangeEventArgs 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 e... — committed to bemberas/Blazor by deleted user 6 years ago
- 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 ... — committed to bemberas/Blazor by deleted user 6 years ago
- 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... — committed to bemberas/Blazor by deleted user 6 years ago
- 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... — committed to bemberas/Blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- 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... — committed to dotnet/blazor by deleted user 6 years ago
- Marshal oninput events as UIChangeEventArgs (#1673) * Marshal oninput events as UIChangeEventArgs - Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This mean... — committed to dotnet/blazor by SteveSandersonMS 6 years ago
- Marshal oninput events as UIChangeEventArgs (#1673) * Marshal oninput events as UIChangeEventArgs - Blazor does handle the oninput event, but it is marshalled as a regular UIEventArgs - This mean... — committed to SteveSandersonMS/BlazorMigration by SteveSandersonMS 6 years ago
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.
<input placeholder="Search" autofocus autocomplete="on" oninput="(this.dispatchEvent(new CustomEvent('change', { bubbles: true })))" bind="@currentSearchTerm" />The oninput function being the important part. (Found this here). Took me some time to find so thought I’d share it at the top result when googling “Blazor oninput”.
@ransagy This
oninput="(this.dispatchEvent(new CustomEvent('change', { bubbles: true })))"is not C# (Blazor) code. It is pure JavaScript. Look here: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events@springy76 it is probably not documented. I have just added this issue https://github.com/aspnet/Blazor.Docs/issues/368. Standard syntax
<input bind="@myVariable" />is exactly the same as<input bind-value-onchange="@myVariable" />which means: create two way data binding forvalueproperty ofinputelement and updatemyVariableeach timeonchangeevent is fired. By analogy<input bind-value-oninput="@FieldValue" />means thatmyVariablewill be updated each timeoninputevent will be fired.Perfect !! Thanks so much !!
Sure @guardrex.
I created a new Issue as suggested. https://github.com/aspnet/AspNetCore/issues/9974
Hello @PirasannaRavi … Please open product feedback over in the aspnet/AspNetCore issues.
@SteveSandersonMS unfortunately your solution doesn’t work. This code
throws exception visible in console:
I can change oninput to onchange
<input bind-value-onchange="@FieldValue" />and it works as standard binding.