Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 generators
Octocat-spinner-32 packages
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Assetfile
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 config.ru
Octocat-spinner-32 project.json
README.md

Development has temporarily been suspended. Please read this blog post.

Ember RouteManager

Ember RouteManager is a coupling of native ember state managers with browser routing mechanisms. In it's current form, it is a modified version of SproutCore Routing which extends Ember.StateManager.

Basic Example

MyApp = Em.Application.create();

MyApp.postsView = Em.View.create({
  template: Em.Handlebars.compile("<h1>POSTS</h1><p>State: {{MyApp.routeManager.currentState.path}}</p>")
});

MyApp.projectsView = Em.View.create({
  template: Em.Handlebars.compile("<h1>PROJECTS</h1><p>State: {{MyApp.routeManager.currentState.path}}</p>")
});

MyApp.routeManager = Ember.RouteManager.create({

  posts: Em.ViewState.create({
    route: 'posts', // defines a static route
    view: MyApp.postsView,

    index: Em.State.create({}), // default state

    show: Em.State.create({
      route: ':id', // defines a nested dynamic route
      enter: function(stateManager, transition) {
        this._super(stateManager, transition);
        var params = stateManager.get('params');
        var postId = params.id;
        // do something here with postId
      }
    })
  }),

  projects: Em.ViewState.create({
    route: 'projects',
    view: MyApp.projectsView
  })

});

With the above route manager defined, you can now change the browser location either directly or by using routeManager.set('location', ...). For instance:

MyApp.routeManager.set('location', 'posts/25');

Will set the routeManager to the 'posts.show' state with the params containing the post id of 25. States with routes can be nested arbitraily deep.

Something went wrong with that request. Please try again.