I am new to jQuery in ASP.NET Core and can't handle this situation. I have a table with data from database and selector with links to other project pages. They can't be triggered and I try to enforce triggering with jQuery.
CSHTML:
<tbody>
@foreach(PersonViewModel pvm in Model)
{ <tr>
<td><a asp-action="Details" asp-controller="Person" asp-route-id="@pvm.Person.PersonID">@pvm.Person.FullName</a></td>
<td>@pvm.Person.Age</td>
.....
@if (pvm.Person.Records.Count != 0)
{<td>
<select id=record_selector>
@foreach(Record r in pvm.Person.Records)
{
if(!r.IsHired){<option value=@r.RecordID>
<a asp-action="Index" asp-controller="Record" asp-route-id="@r.RecordID">Not Hired @r.RecordNumber</a></option>}
if(r.IsHired){<option value=@r.RecordID>
<a asp-action="Index" asp-controller="Record" asp-route-id="@r.RecordID">Hired @r.RecordNumber</a></option>}
}
</select>
</td>}
@if (pvm.Patient.Records.Count == 0)
{<td><a asp-action="CreateUpdateRecord" asp-controller="Admin">Create new record</a></td>}
</tr>}
</tbody>
Later:
<script>
$(function(){
$("#record_selector").click(function(){
$((this.children:selected).children("a")).click;
});
});
I added jquery as a nuget package and a link <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
in my layout file. It still doew not work. Could youhelp me please?