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