working but with errors…

This commit is contained in:
Sacha Greif 2013-10-12 13:10:33 +09:00
parent 9eb6e7afab
commit 745fa28370
2 changed files with 5 additions and 7 deletions

View file

@ -248,7 +248,6 @@ Router.map(function() {
waitOn: postsSubscriptions.top = postListSubscription(selectTop, sortPosts('score'), 10), waitOn: postsSubscriptions.top = postListSubscription(selectTop, sortPosts('score'), 10),
after: function() { after: function() {
Session.set('view', 'top'); Session.set('view', 'top');
currentSubscription = postsSubscriptions.top;
} }
}); });
@ -258,7 +257,6 @@ Router.map(function() {
waitOn: postsSubscriptions.top = postListSubscription(selectTop, sortPosts('score'), 11), waitOn: postsSubscriptions.top = postListSubscription(selectTop, sortPosts('score'), 11),
after: function() { after: function() {
Session.set('view', 'top'); Session.set('view', 'top');
currentSubscription = postsSubscriptions.top;
} }
}); });
@ -270,7 +268,6 @@ Router.map(function() {
waitOn: postsSubscriptions.new = postListSubscription(selectNew, sortPosts('submitted'), 12), waitOn: postsSubscriptions.new = postListSubscription(selectNew, sortPosts('submitted'), 12),
after: function() { after: function() {
Session.set('view', 'new'); Session.set('view', 'new');
currentSubscription = postsSubscriptions.new;
} }
}); });

View file

@ -1,12 +1,13 @@
Template.posts_list.helpers({ Template.posts_list.helpers({
posts: function() { posts: function() {
return currentSubscription.fetch(); console.log(postsSubscriptions[Session.get('view')])
return postsSubscriptions[Session.get('view')].fetch();
}, },
postsReady: function() { postsReady: function() {
return currentSubscription.ready(); return postsSubscriptions[Session.get('view')].ready();
}, },
allPostsLoaded: function(){ allPostsLoaded: function(){
allPostsLoaded = currentSubscription.fetch().length < currentSubscription.loaded(); allPostsLoaded = postsSubscriptions[Session.get('view')].fetch().length < postsSubscriptions[Session.get('view')].loaded();
Session.set('allPostsLoaded', allPostsLoaded); Session.set('allPostsLoaded', allPostsLoaded);
return allPostsLoaded; return allPostsLoaded;
} }
@ -25,7 +26,7 @@ Template.posts_list.events({
'click .more-link': function(e) { 'click .more-link': function(e) {
e.preventDefault(); e.preventDefault();
Session.set('currentScroll',$('body').scrollTop()); Session.set('currentScroll',$('body').scrollTop());
currentSubscription.loadNextPage(); postsSubscriptions[Session.get('view')].loadNextPage();
} }
}); });