그것은 다음과 같이해야한다 : 당신이
@Ajax.ActionLink(
"Delete",
"Delete",
"AdminGroup",
new { id = item.AdminGroupId },
new AjaxOptions {
Confirm = "Delete?",
HttpMethod = "Delete",
OnSuccess = "handleSuccess"
}
)
: 여기
<script type="text/javascript">
function handleSuccess() {
// TODO: handle the success
// be careful because $(this) won't be
// what you think it is in this callback.
}
</script>
대안 솔루션입니다 내가 당신을 추천 할 것입니다 :
@Html.ActionLink(
"Delete",
"Delete",
"AdminGroup",
new { id = item.AdminGroupId },
new { id = "delete" }
)
과 그 다음에 .. parate 자바 스크립트 파일 링크 AJAXify :
$(function() {
$('#delete').click(function() {
if (confirm('Delete?')) {
var $link = $(this);
$.ajax({
url: this.href,
type: 'DELETE',
success: function(result) {
$link.parent().parent().remove();
}
});
}
return false;
});
});
이 "$ (이) .parent을 반환 어쨌든이을() 부모()를 제거(); : 컨트롤러에서 실행하고 실행 하시겠습니까? – ShaneKm
@Shane, 컨트롤러에서 당신은'$ (this)) .parent(). parent(). remove(); ");를 호출 할 수 있지만'$ (this) 당신은 기대할 수 있습니다. 개인적으로 나는 컨트롤러가 자바 스크립트를 반환하지 않았을 것이다. 나는 성공 콜백에서 그것을 처리 할 것이다. –
@Darin, Darin이 Ajax를 추천하지 않는다고 생각해야합니까? ActionLink? 감사합니다 –