In my blazor app,
...
<td>
<input type="text" style="border:none;" @bind="todo.Title" />
</td>
...
How can I get access in the @code section of the text changed value and the todo item that is related to it? Is a "after change is bound to the todo" event I can hook into to?
Currently, I can get the change event and it has the changed value but I don't have access to the todo item related to it. Or I can get access to todo item but I don't have access to what the text changed value is.
@page "/todo"
<pagetitle>Todo</pagetitle>
<h1>Todo (@todos.Count(todo => !todo.IsDone))</h1>
<table>
@foreach (var todo in todos)
{
<tr>
<td>
<input type="checkbox" @bind="todo.IsDone" />
</td>
<td>
<input type="text" style="border:none;" @bind="todo.Title" />
@todo.RsDisplay
</td>
</tr>
}
</table>
<input placeholder="Something todo" @bind="newTodo" />
<button @onclick="AddTodo">Add todo</button>
@code {
private List<TodoItem> todos = new();
private string? newTodo;
private void AddTodo()
{
if (!string.IsNullOrWhiteSpace(newTodo))
{
todos.Add(new TodoItem { Title = newTodo, RsDisplay = "test" });
newTodo = string.Empty;
}
}
}