Skip to content

Instantly share code, notes, and snippets.

@txominpelu
Created August 22, 2012 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save txominpelu/3429945 to your computer and use it in GitHub Desktop.
Save txominpelu/3429945 to your computer and use it in GitHub Desktop.
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