Your deleteComment()
function is buried within two layers of other functions, so there's no way your inline JavaScript can access it. I suggest (1) taking it out of your done
callback because there's no reason for it to be there and (2) using unobtrusive JavaScript for this:
HTML:
<a href="#" class="delete-comment" data-commentid="@item.CommentId">Delete</a>
JavaScript:
$(function () {
var hub = $.connection.commentsHub;
function deleteComment(commentId) {
hub.server.DeleteComment(commentId);
}
$.connection.hub.start().done(function () {
$(".delete-comment").click(function() {
deleteComment($(this).attr("data-commentid"));
});
});
});