diff --git a/app/assets/javascripts/app/pages/single-post-viewer.js b/app/assets/javascripts/app/pages/single-post-viewer.js index a145139b5..f12f45a33 100644 --- a/app/assets/javascripts/app/pages/single-post-viewer.js +++ b/app/assets/javascripts/app/pages/single-post-viewer.js @@ -11,7 +11,6 @@ app.pages.SinglePostViewer = app.views.Base.extend({ initialize : function() { this.model = new app.models.Post(gon.post); this.initViews(); - this.model.comments.fetch(); // async, yo, might want to throttle this later. }, initViews : function() { diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js index 49ddf11db..3e8ea0ea3 100644 --- a/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js +++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js @@ -8,6 +8,9 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({ $(window).on('hashchange',this.highlightPermalinkComment); this.setupBindings(); this.model.comments.on("reset", this.render, this); + this.model.comments.fetch({success: function() { + setTimeout(this.highlightPermalinkComment, 0); + }.bind(this)}); }, highlightPermalinkComment: function() { @@ -17,14 +20,13 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({ $(".highlighted").removeClass("highlighted"); element.addClass("highlighted"); var pos = element.offset().top - headerSize; - window.scroll(0, pos); + $("html,body").animate({scrollTop: pos}); } }, postRenderTemplate: function() { app.views.CommentStream.prototype.postRenderTemplate.apply(this); this.$(".new-comment-form-wrapper").removeClass("hidden"); - _.defer(this.highlightPermalinkComment); }, presenter: function(){