Skip to content

theotherzach/Meteor-Leaderboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meteor Leaderboard

##Live demo

Original leaderboard example from the MeteorJS site. It's startling how easy it is to get work done in Meteor; wouldn't be surprised if it's the next de facto Web framework.

The new sort button, sans logic.

  <div class="controller">
    <button id="sort">Sort by {{sort_order}}</button>
  </div>
  Template.leaderboard.sort_order = function () {
    // Passes a string back to the sort button based on the sort order.
    var order = "Score";
    if (Session.get("is_name_order")) {
      order = "Name";
    }
    return order;
  };
    'click #sort': function () {
      // Our button switch
      Session.set("is_name_order", !Session.get("is_name_order"));
    }
  Template.leaderboard.players = function () {
    // Ended up stealing this bit of code to get me started. 
    // Here is where we actually change the sort.
    var order = Session.get("is_name_order") ?
    {name: 1, score: -1} :
    {score: -1, name: 1};
    return Players.find({}, {sort: order});
	};

About

Meteor Leaderboard Example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published