Created
August 22, 2012 22:12
-
-
Save txominpelu/3429945 to your computer and use it in GitHub Desktop.
Full code for the tutorial on ember.js states
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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