I have a list with paging integration.
This is how list is coming-
foreach(var item in Model)
{
<tr id="[email protected]">
<td>
@Html.DisplayFor(modelItem => item.vendorName)
</td>
<td>
@Html.DisplayFor(modelItem => item.vendor_Representative)
</td>
<td>
@Html.DisplayFor(modelItem => item.fixed_Line)
</td>
<td>
@Html.DisplayFor(modelItem => item.mobile_No)
</td>
<td>
@Html.DisplayFor(modelItem => item.fax_No)
</td>
<td>
@Html.DisplayFor(modelItem => item.emaiL)
</td>
<td>
@Html.DisplayFor(modelItem => item.addresS)
</td>
<td>
@Html.DisplayFor(modelItem => item.rep_Contact)
</td>
<td>
<span class="dropdown settings">
<a href="javascript:;" class="btn btn-default btn-mini dropdown-toggle options"
data-toggle="dropdown"><i class="fa fa-cogs"></i></a>
<ul class="dropdown-menu arrow pull-right">
<li>
<a href="javascript:;"><i class="fa fa-pencil"></i> Edit</a>
</li>
<li>
<a href="javascript:;" id="[email protected]"><i class="fa fa-lock"></i>
Delete
</a>
</li>
</ul>
</span>
</td>
</tr>
}
Now I wanted to Delete row from this list.
For the first page it works fine and retrieves me back with alert with an id of current row.
But as soon as I click on second page from paging below It deleting row doesn't trigger the row's id.
jQuery-
<script type="text/javascript">
$(function () {
$(document).on('click', 'a[id^="[email protected]"]', function () {
var $this = $('a[id^="[email protected]"]');
var id = $this.parent().parent().parent().parent().parent().attr('id');
alert(id);
$.ajax({
url: '/Vendors/DeactivateVendor/@item.Id',
type: 'POST',
success: function (data) {
if (data.success == true) {
$('#' + '[email protected]').remove();
}
else {
window.location.href = "/UserAccount/Login/";
}
}
});
});
});
</script>
Above jQuery only works for first page that is existed in document now.
How Do I create click function for dynamically coming list after document changes to next page.
On first page-

On second page-
