Skip to content

Instantly share code, notes, and snippets.

@joliss
Created May 25, 2012 14:51
Show Gist options
  • Save joliss/2788545 to your computer and use it in GitHub Desktop.
Save joliss/2788545 to your computer and use it in GitHub Desktop.
Ember routing example
# 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()
@joliss
Copy link
Author

joliss commented May 26, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment