Ember.js Starter Kit
Based on latest version of Ember.js with the new router. (latest ember build from 2013-01-06)
HTML
<script src="https://github.com/downloads/wycats/handlebars.js/handlebars-1.0.rc.1.js"></script>
<script src="https://gist.github.com/raw/4469745/b102ee742d0c014bdb21715525255069d0b828bb/ember-latest-201301062045.js"></script>
<script type="text/x-handlebars" data-template-name="application">
<h1>Hello from Ember.js</h1>
{{outlet}}
{{currentPath}}
{{#linkTo "usersIndex"}}goto user{{/linkTo}}
{{#linkTo "newUser"}}add a new user{{/linkTo}}
</script>
<script type="text/x-handlebars" data-template-name="usersIndex">
this is a user
</script>
<script type="text/x-handlebars" data-template-name="newUser">
<h2>Create a new user</h2>
<input type="text"/>
</script>
JavaScript
App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.Router = Ember.Router.extend();
App.Router.map(function(match) {
match("/").to("home");
match("/users").to("users", function(match) {
match("/").to("usersIndex");
match("/new").to("newUser");
});
});
App.IndexRoute = Ember.Route.extend({
redirect: function () {
alert('hi');
this.transitionTo('users.usersIndex');
}
});