Last active
November 2, 2015 02:27
-
-
Save firrae/5f439a55d4d604a96a73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dashboard = React.createClass({ | |
mixins: [ ReactMeteorData ], | |
getMeteorData() { | |
let subscription = Meteor.subscribe( 'newsFeed' ); | |
let page = new ReactiveVar(); | |
page.set(0); | |
return { | |
isLoading: !subscription.ready(), | |
news: News.find({}, {limit: 3, skip: (page.get() * 3), sort: {createdDate: 1}}).fetch(), | |
page: page, | |
totalCount: Counts.get( 'newsCounter' ) | |
}; | |
}, | |
componentDidMount() { | |
}, | |
newer() { | |
this.data.page.set(this.data.page.get() + 1); | |
console.log(this.data.page.get()); | |
}, | |
older() { | |
if(this.data.page.get() > 0) | |
this.data.page.set(this.data.page.get() - 1); | |
console.log(this.data.page.get()); | |
}, | |
render() { | |
if ( this.data.isLoading ) { | |
return <Loading />; | |
} else { | |
return ( | |
<div> | |
<NewsList news={this.data.news} /> | |
<ul className="pager"> | |
<li className={this.data.page.get() <= 0 ? 'previous disabled' : 'previous' } onClick={this.older}><a href="#">← Older</a></li> | |
<li className="next" onClick={this.newer}><a href="#">Newer →</a></li> | |
</ul> | |
</div> | |
); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment