Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Created April 9, 2012 05:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmarkoh/2341576 to your computer and use it in GitHub Desktop.
Save markmarkoh/2341576 to your computer and use it in GitHub Desktop.
Example Ember.StateManager
App.stateManager = Ember.StateManager.create({
//Swap state within this element
rootElement: "#appRoot",
//Simple State
overview: Ember.ViewState.create({
view: App.Overview
}),
//More Advanced State
highestRated: Ember.ViewState.create({
view: App.HighestRated,
//when entering this state
enter: function( stateManager ) {
this._super( stateManager );
//silly sort content
App.productList.set('content',
_.sortBy( App.productList.content, function( product ) { return 0 - product.rating })
)
}
})
});
//Usage
App.stateManager.goToState( 'overview' );
App.stateManager.currentState.name === 'overview';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment