Skip to content
JavaScript Ruby
Latest commit 84d6abd Jul 2, 2012 @ghempton Update master
Failed to load latest commit information.
generators
packages Merge pull request #13 from josepjaume/master May 12, 2012
tests jslint warnings fixed; testsuite fixed (package=all) Feb 21, 2012
.gitignore Removed dependency on old internal Route class. Feb 1, 2012
Assetfile Initial commit. Jan 29, 2012
Gemfile Initial commit. Jan 29, 2012
Gemfile.lock Initial commit. Jan 29, 2012
LICENSE Initial commit. Jan 29, 2012
README.md Update master Jul 2, 2012
Rakefile Initial commit. Jan 29, 2012
VERSION Initial commit. Jan 29, 2012
config.ru Initial commit. Jan 29, 2012
project.json Initial commit. Jan 29, 2012

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.