Merge pull request #166 from ZmagoD/zd_SCI_471

fixes load comments [fixes SCI-471]
This commit is contained in:
Zmago Devetak 2016-09-23 09:17:27 +02:00 committed by GitHub
commit 2b678998d3

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
@ -130,9 +131,10 @@
.change(function() { .change(function() {
$(".step-save") $(".step-save")
.on("click", function() { .on("click", function() {
setTimeout(function() { $(document)
initializeComments(); .on('ajax:success', function(){
}, 500); initializeComments();
});
}); });
}); });
} else if ( document.getElementById("results") !== null ) { } else if ( document.getElementById("results") !== null ) {
@ -140,9 +142,10 @@
.change(function() { .change(function() {
$(".save-result") $(".save-result")
.on("click", function() { .on("click", function() {
setTimeout(function() { $(document)
initializeComments(); .on('ajax:success', function(){
}, 500); initializeComments();
});
}); });
}); });
} }