Canonical Ember.js routing example

by Kasper Tidemann

Notice: since the time of writing, this has been changed in Ember.js. Please take a look at this post instead.

Ember.js is on the rise with more and more people embracing the framework for creating client-side web applications. The community is focusing heavily on the development these days, making changes and commits on an hourly basis.

A couple of days ago, routing was moved out of Ember.State and into Ember.Route, paving the way for new routing examples based on the latest conventions. Alas, I bring you my canonical routing example using Ember.js:

First of all, I have put up a live version of the example code here.

Now, the example consists of an index.html file containing trivial HTML plus the Handlebars templates used. All JavaScript files reside in the js/ folder. Finally, for the CoffeeScript lovers, there is an app.coffee file in the src/ folder.

Should you wish to download the example files, I have a ZIP file available right here. There is also a GitHub repository containing the project.

I did my best to comment everything, including the use of Em.run.next() for making the effects work on the initial load. If you have any questions, please let me know or join us at #emberjs on irc.freenode.org. Enjoy!