diff --git a/public/javascripts/app/router.js b/public/javascripts/app/router.js index 7ad506786..dd07d2a9b 100644 --- a/public/javascripts/app/router.js +++ b/public/javascripts/app/router.js @@ -5,15 +5,14 @@ App.Router = Backbone.Router.extend({ "like_stream": "stream", "mentions": "stream", "people/:id": "stream", + "u/:name": "stream", "tag_followings": "stream", "tags/:name": "stream", "posts/:id": "stream" }, stream: function() { - App.stream = new App.Views.Stream; + App.stream = new App.Views.Stream().render(); $("#main_stream").html(App.stream.el); - - App.stream.loadMore(); } }); diff --git a/public/javascripts/app/views/stream_view.js b/public/javascripts/app/views/stream_view.js index afba1a179..255fdb37a 100644 --- a/public/javascripts/app/views/stream_view.js +++ b/public/javascripts/app/views/stream_view.js @@ -1,17 +1,12 @@ App.Views.Stream = Backbone.View.extend({ events: { - "click #paginate": "loadMore" + "click #paginate": "render" }, initialize: function() { - _.bindAll(this, "collectionFetched"); - this.collection = this.collection || new App.Collections.Stream; this.collection.bind("add", this.appendPost, this); - }, - render : function(){ - _.each(this.collection.models, this.appendPost, this) return this; }, @@ -28,20 +23,29 @@ App.Views.Stream = Backbone.View.extend({ }).text('Load more posts')); }, - loadMore: function(evt) { + render : function(evt) { if(evt) { evt.preventDefault(); } - this.addLoader(); - this.collection.fetch({ + var self = this; + self.addLoader(); + self.collection.fetch({ add: true, - success: this.collectionFetched + success: $.proxy(this.collectionFetched, self) }); + + return this; }, addLoader: function(){ + if(this.$("#paginate").length == 0) { + $(this.el).append($("