Created
April 21, 2012 05:53
-
-
Save zymsys/2434519 to your computer and use it in GitHub Desktop.
Meteor First Impressions
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
Template.leaderboard.events = { | |
'click input.inc': function () { | |
Players.update(Session.get("selected_player"), {$inc: {score: 5}}); | |
}, | |
'click #sort': function () { | |
Session.set("sort_by_name", !Session.get("sort_by_name")); | |
} | |
}; |
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
Template.leaderboard.players = function () { | |
var sort = Session.get("sort_by_name") ? | |
{name: 1, score: -1} : | |
{score: -1, name: 1}; | |
return Players.find({}, {sort: sort}); | |
}; |
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
Template.leaderboard.sort_by_name = function () { | |
return Session.get("sort_by_name"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment