DH DG; added new routes for streams; fixed pagination

This commit is contained in:
danielgrippi 2011-12-08 16:47:28 -08:00 committed by Dennis Collinson
parent 80f797a581
commit 3f7d992a0b
9 changed files with 28 additions and 12 deletions

View file

@ -20,8 +20,8 @@ javascripts:
- public/javascripts/collections/*
- public/javascripts/views/*
- public/javascripts/routers/stream.js
- public/javascripts/routers/*
- public/javascripts/routers/stream/*
- public/javascripts/rails.validations.js
- public/javascripts/rails.js

View file

@ -1,5 +0,0 @@
App.Routers.CommentStream = App.Routers.Stream.extend({
routes: {
"comment_stream": "stream"
}
});

View file

@ -5,5 +5,8 @@ App.Routers.Stream = Backbone.Router.extend({
stream: function() {
App.stream = new App.Views.Stream;
$("#main_stream").html(App.stream.el);
App.stream.loadMore();
}
});

View file

@ -0,0 +1,5 @@
App.Routers.Comments = App.Routers.Stream.extend({
routes: {
"comment_stream": "stream"
}
});

View file

@ -0,0 +1,5 @@
App.Routers.People = App.Routers.Stream.extend({
routes: {
"people/:id": "stream"
}
});

View file

@ -0,0 +1,5 @@
App.Routers.TagFollowings = App.Routers.Stream.extend({
routes: {
"tag_followings": "stream"
}
});

View file

@ -0,0 +1,5 @@
App.Routers.Tags = App.Routers.Stream.extend({
routes: {
"tags/:id": "stream"
}
});

View file

@ -3,14 +3,11 @@ App.Views.Stream = Backbone.View.extend({
"click #paginate": "loadMore"
},
initialize: function(){
this.el = $("#main_stream");
_.bindAll(this, "appendPost", "collectionFetched");
initialize: function() {
_.bindAll(this, "appendPost", "collectionFetched", "loadMore");
this.collection = new App.Collections.Stream;
this.collection.bind("add", this.appendPost);
this.loadMore();
},
appendPost: function(post) {
@ -23,7 +20,8 @@ App.Views.Stream = Backbone.View.extend({
this.$("#paginate").remove();
$(this.el).append($("<a>", {
href: this.collection.url(),
id: "paginate"
id: "paginate",
"class": "paginate"
}).text('more'));
},