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() |
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
I just pulled from master and it's almost working like you describe. On L#14 I have to include the state I want to transition to
manager.transitionTo('elections.index')
or I get an error "You need to provide an object and key toget
".I've been trying to piece together some working code (from router to view) from both this gist and @wycats one (posted a couple of days ago - https://gist.github.com/2728699) and can't seem to get it right... https://gist.github.com/2791272. If I include:
before the call to
appController.connectOutlet(App.UsersView, App.User.find());
the template gets rendered but from what I understood there was a helper called {{outlet}} that I could hook into.Any thoughts?