Added check if no comments are present for file result, which caused JS error.

This commit is contained in:
Matej Zrimšek 2016-09-22 17:57:04 +02:00
parent 303cb4308a
commit 0317872bc0

View file

@ -12,9 +12,10 @@
} else if ( $(".result-comment") && $(".result-comment").length > 0 ) { } else if ( $(".result-comment") && $(".result-comment").length > 0 ) {
comments = $(".result-comment"); comments = $(".result-comment");
} }
if(!_.isUndefined(comments)) {
$.each(comments, function(){ $.each(comments, function(){
var that = $(this); var that = $(this);
var link = that.attr("data-href"); var link = that.attr('data-href');
$.ajax({ method: 'GET', $.ajax({ method: 'GET',
url: link, url: link,
beforeSend: animateSpinner(that, true) }) beforeSend: animateSpinner(that, true) })
@ -22,14 +23,14 @@
that.html(data.html); that.html(data.html);
initCommentForm(that); initCommentForm(that);
initCommentsLink(that); initCommentsLink(that);
scrollBottom(that.find(".content-comments")); scrollBottom(that.find('.content-comments'));
animateSpinner(that, false);
}) })
.always(function() { .always(function() {
animateSpinner(that, false); animateSpinner(that, false);
}); });
}); });
} }
}
// scroll to the botttom // scroll to the botttom
function scrollBottom(id) { function scrollBottom(id) {