Fix comment highlightning in the SPV
This commit is contained in:
parent
5808b84e83
commit
55349162bd
2 changed files with 4 additions and 3 deletions
|
|
@ -11,7 +11,6 @@ app.pages.SinglePostViewer = app.views.Base.extend({
|
||||||
initialize : function() {
|
initialize : function() {
|
||||||
this.model = new app.models.Post(gon.post);
|
this.model = new app.models.Post(gon.post);
|
||||||
this.initViews();
|
this.initViews();
|
||||||
this.model.comments.fetch(); // async, yo, might want to throttle this later.
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initViews : function() {
|
initViews : function() {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
|
||||||
$(window).on('hashchange',this.highlightPermalinkComment);
|
$(window).on('hashchange',this.highlightPermalinkComment);
|
||||||
this.setupBindings();
|
this.setupBindings();
|
||||||
this.model.comments.on("reset", this.render, this);
|
this.model.comments.on("reset", this.render, this);
|
||||||
|
this.model.comments.fetch({success: function() {
|
||||||
|
setTimeout(this.highlightPermalinkComment, 0);
|
||||||
|
}.bind(this)});
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightPermalinkComment: function() {
|
highlightPermalinkComment: function() {
|
||||||
|
|
@ -17,14 +20,13 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
|
||||||
$(".highlighted").removeClass("highlighted");
|
$(".highlighted").removeClass("highlighted");
|
||||||
element.addClass("highlighted");
|
element.addClass("highlighted");
|
||||||
var pos = element.offset().top - headerSize;
|
var pos = element.offset().top - headerSize;
|
||||||
window.scroll(0, pos);
|
$("html,body").animate({scrollTop: pos});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
postRenderTemplate: function() {
|
postRenderTemplate: function() {
|
||||||
app.views.CommentStream.prototype.postRenderTemplate.apply(this);
|
app.views.CommentStream.prototype.postRenderTemplate.apply(this);
|
||||||
this.$(".new-comment-form-wrapper").removeClass("hidden");
|
this.$(".new-comment-form-wrapper").removeClass("hidden");
|
||||||
_.defer(this.highlightPermalinkComment);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
presenter: function(){
|
presenter: function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue