Created
May 25, 2012 14:51
-
-
Save joliss/2788545 to your computer and use it in GitHub Desktop.
Ember routing example
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
# Works against Ember HEAD. | |
# Note the routing still changes a lot. This might not work tomorrow. | |
window.App = Ember.Application.create() | |
App.Router = Ember.Router.extend | |
location: 'hash' # hopefully it will auto-pick and support HTML5 in the future | |
root: Ember.State.extend | |
index: Ember.State.extend | |
route: '/' | |
connectOutlets: (manager) -> | |
manager.transitionTo('elections') | |
elections: Ember.State.extend | |
route: '/elections' | |
index: Ember.State.extend | |
route: '/' | |
connectOutlets: (manager) -> | |
show: Ember.State.extend | |
route: '/:election_id' | |
modelType: App.Election # this is an ember-data model, which has an id | |
connectOutlets: (manager, election) -> | |
console.log(election) | |
# This auto-instantiates the router class found at App.Router and starts the routing | |
App.initialize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, I'm not sure yet what they even mean by
outlet
, terminology-wise.I haven't hooked up controllers and views with my routing yet, but I'm expecting there's some kind of pattern this is meant to be used with. I'll go have a stab at it on Monday night. Maybe some gists or docs will have turned up by then, else I'll ask around on #emberjs.