I have this page
<script type="text/javascript">
$(document).ready(function () {
$("#delete").click(function () {
if (confirm) {
$("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/")');
}
else {
return false;
}
});
});
</script>
<table>
<tr>
<td>Description</td>
<td>Schedule</td>
<td> </td>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Description</td>
<td>@item.Schedule</td>
<td><a href="@Url.Action("ScheduleEdit", new { @id = item.Id })" class="popLink"><img alt="" src="@Url.Content("~/Content/images/icons/edit.gif")" style="border:none;" /></a>
<img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" id="delete" /></td>
</tr>
}
</table>
The Jquery function there is being triggered by elements with id="delete", for instance, a img tag.
Can someone help me please, I need to have this Jquery function to have a parameter passed using onclick like for example
$(document).ready(function () {
$("#delete").click(function (id) {
if (confirm) {
$("#divSchedules").load('@Url.Content("~/Export/ScheduleDelete/" + id)');
}
else {
return false;
}
});
});
<img alt="" src="@Url.Content("~/Content/images/icons/delete.gif")" style="border:none;" onclick="delete(@item.Id)" />
I have added id on jquery as parameter. I tried that but always having compile error "id not in context" thing.
Could someone please help? Thank you very much.