2021年3月23日星期二

Blazor WASM Button Onclick not firing every time

I have a table with the summary of items, and when i click on a button i have a modal pop up with addition information about that item. Unfortunately, for some reason, Blazor will not always pop up the modal. It's gotten to the point where i've simplified the code to just do a Console.WriteLine("Person Id: Id") and i'm still seeing the issue.

@foreach(var p in people){    <tr>      <td><button type="button" class="btn btn-outline-info" @onclick="(async()=>await ShowPerson(p))">@p.FirstName</button>      </td>      <td>@p.LastName</td>    </tr>  }  

then in the code section

List<Person> people { get; set; }  ...  async Task ShowPerson(Person p){    Console.WriteLine("Click");    selectedPerson = p;    await _jsRuntime.InvokeVoidAsync("toggleModal", "personModal");  }  

then in my js file the toggleModal just does a $("#" + id).modal('toggle');

now when i'm watching the console, I can click a button and there is a chance that nothing shows up in the console, and the modal doesn't open. Or the Click shows up in the console and the modal pops up. Has anyone come across this, or see anything obvious from the code above?

Thanks

https://stackoverflow.com/questions/66774180/blazor-wasm-button-onclick-not-firing-every-time March 24, 2021 at 11:07AM

没有评论:

发表评论