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