I have the following html structure created dynamically using a foreach loop and trying to delete an entire element by accessing it from (ACTIVE HYPERLINK). I tried many different ways, but I can not reach it. Since the entire block (ACTIVE HYPERLINK) is repeated, I think it makes no sense to use the name of the hyperlink class. I also tried using a.active, but didn't seem to work.
@foreach (var file in Model.FileAttachments)
{
<li class="aaa">
<div class="bbb">
<div class="ccc">
<div class="ddd">
<div class="eee">
<ul class="fff">
<li>
<a class="xxx" href="javascript:void(0);" data-id="@file.Id" data-toggle="confirmation" ></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
}
<script>
$('.xxx').click(function (e) {
e.preventDefault();
$('[data-toggle="confirmation"]').confirmation('show');
});
$('[data-toggle="confirmation"]').confirmation({
onConfirm: function () { deleteRecord(); },
});
function deleteRecord() {
var $ctrl = $('.xxx');
$.ajax({
success: function (response, textStatus, XMLHttpRequest) {
if (response.success) {
ctrl.closest('.aaa').remove();
$("a.active").closest('.jFiler-item').remove();
}
});
};
</script>
Here is an example of my attempts:
$("a.active").closest('.aaa').remove();
$(".xxx").closest('.aaa').remove();
$(this).data('.aaa')remove();
$("a.active").parents('li').eq(2)remove();
$(".xxx").parents('li').eq(2)remove();
Any idea?
source
share