Create a gist now

Instantly share code, notes, and snippets.

Full code for the tutorial on ember.js states
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Playing with ember states</title>
<script src="http://code.jquery.com/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="handlebars.js" type="text/javascript" charset="utf-8"></script>
<script src="ember-1.0.pre.debug.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<script type="text/x-handlebars" data-template-name="master">
This is the master section.
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="main">
My main with its context: {{ variable }}.
</script>
<script src="states.js" type="text/javascript" charset="utf-8"></script>
</body>
<html>
App = Ember.Application.create({
ApplicationController : Ember.Controller.extend({
}),
ApplicationView : Ember.View.extend({
templateName: "master"
}),
MainView : Ember.View.extend({
templateName: "main"
}),
MainController : Ember.Controller.extend({
variable: "my main var"
}),
Router : Ember.Router.extend({
root: Ember.Route.extend({
main: Ember.Route.extend({
route: '/main/',
connectOutlets: function(router, event) {
router.get('applicationController').connectOutlet('main');
}
})
})
})
});
$(function() {
App.initialize();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment