use el.on("click") to load more comments and prevent default

This commit is contained in:
Martin Zimmermann 2014-05-27 23:18:14 +02:00
parent d0a50c7905
commit 94ee6a6981

View File

@ -67,38 +67,37 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
entrypoint.append(el); entrypoint.append(el);
$("a.load_hidden", el).toggle("click", $("a.load_hidden", el).on("click", function() {
function() { el.remove();
el.remove(); api.fetch($("#isso-thread").getAttribute("data-isso-id"),
api.fetch($("#isso-thread").getAttribute("data-isso-id"), config["reveal-on-click"], config["max-comments-nested"],
config["reveal-on-click"], config["max-comments-nested"], comment.id,
comment.id, lastcreated).then(
lastcreated).then( function(rv) {
function(rv) { if (rv.total_replies === 0) {
if (rv.total_replies === 0) { return;
return; }
}
var lastcreated = 0; var lastcreated = 0;
rv.replies.forEach(function(commentObject) { rv.replies.forEach(function(commentObject) {
insert(commentObject, false); insert(commentObject, false);
if(commentObject.created > lastcreated) { if(commentObject.created > lastcreated) {
lastcreated = commentObject.created; lastcreated = commentObject.created;
}
});
if(rv.hidden_replies > 0) {
insert_loader(rv, lastcreated);
} }
if (window.location.hash.length > 0) {
$(window.location.hash).scrollIntoView();
}
},
function(err) {
console.log(err);
}); });
});
if(rv.hidden_replies > 0) {
insert_loader(rv, lastcreated);
}
if (window.location.hash.length > 0) {
$(window.location.hash).scrollIntoView();
}
},
function(err) {
console.log(err);
});
});
}; };
var insert = function(comment, scrollIntoView) { var insert = function(comment, scrollIntoView) {