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