I have an Ajax.Actionlink for delete with confirm message, but the confirm message will show up twice after the first deletion when clicked “OK”.
Basically, when I delete the first record, the confirm message show. I click on ok, the delete happens and the partial view list rerender. I click on another record for delete, the confirm message show. I click on “OK”, weird thing happen – the record is deleted, but the confirm message popup again.
@Ajax.ActionLink("Delete",
"Delete",
new { id = item.AnnouncementSID },
new AjaxOptions
{
Confirm = "Are you sure you want to delete this announcement?",
HttpMethod = "POST",
UpdateTargetId = "divAnnounceList"
}, new { @class = "actionLink" })
@Scripts.Render("~/Scripts/jquery.unobtrusive-ajax.min.js")
For clarification to future searchers.:
The problem here is that you are calling the Delete action with AJAX and this action is performing a Redirect to the Announcements action. Except that the Announcement action is returning a full HTML instead of a partial. So you get the jquery.unobtrusive-ajax.js injected twice into your DOM. So you get 2 confirmations on the second delete, 3 on the third and so on.
Think this is what is happening