@inject IJSRuntime JS @inject State State @inject RestService api
@code { private Pic? _pic; public Pic? Pic { get => _pic; set { _pic = value; Description = _pic?.Description; } } public string? Description { get; set; } private bool loading = false; [Parameter] public string id { get; set; } protected override async Task OnInitializedAsync() { Description = Pic?.Description; } public async Task PostPic() { loading = true; await InvokeAsync(StateHasChanged); if(!string.IsNullOrEmpty(Pic.Id)) { await api.PostPicDescription(State.SelectedAddressName, Pic.Id, Description); await State.RefreshPics(); await InvokeAsync(StateHasChanged); } await JS.InvokeVoidAsync("ui", "#" + id); // clear input Description = string.Empty; Pic = null; loading = false; await InvokeAsync(StateHasChanged); } }