I am new to Razor pages so please bear with me. I have a table which is populated as follows on my page:
Clicking on the last column opens up a modal popup:
Which has a button to Delete the row that was selected. I cannot however seem to figure out how I would pass the ID of the selected row from the table into the DeleteSeasonTrip()
javascript function where I post an Ajax call to delete the chosen row.
I thought that I might be able to populate a hidden field on the row click and get it from there but wonder if there would be a better solution.
first add css class "itemfieldId" and id on button that open the model as shown
<a id="@item.ID" class="itemfieldId" data-toggle="model" data-
target="#deleteSeasonModel">Delete</a>
then add hidden field in modal popup
<input type="hidden" id="hdnselectedfieldId" />
add script
$(".itemfieldId").on("click", function ()
{
$("#hdnselectedfieldId").val($(this).attr('id'));
})
and now you have itemid in hidden field which you can send
DeleteSeasonTrip()
{
var itemId = $("#hdnselectedfieldId").val();
}