Skip to content

Instantly share code, notes, and snippets.

@noorbakerally
Last active August 29, 2015 14: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 noorbakerally/c5fe53eb645766846631 to your computer and use it in GitHub Desktop.
Save noorbakerally/c5fe53eb645766846631 to your computer and use it in GitHub Desktop.
Ember Starter Kit// source http://jsbin.com/sihili
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/tags/v1.8.0/ember.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.0.0-beta.12/ember-data.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.3/jquery.mockjax.js"></script>
</head>
<body>
<script type="text/x-handlebars">
Sidebar:{{outlet sidebar}}<br/>
Main:{{outlet main}}
</script>
<script type="text/x-handlebars" data-template-name="main">
Category: {{selectedCategory}}
</script>
<script type="text/x-handlebars" data-template-name="sidebar">
Category: {{selectedCategory}} <button {{ action 'setCategory' }}>Change to 3</button>
</script>
</body>
</html>
window.App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter.extend();
App.IndexRoute = Ember.Route.extend({
renderTemplate: function() {
this.render('sidebar', {into: 'application' ,outlet:'sidebar',controller:'SidebarCategories'});
this.render('main', { into: 'application' ,outlet:'main', controller:'MainLinks' });
}
});
App.SidebarCategoriesController = Ember.ObjectController.extend({
selectedCategory:5,
actions: {
setCategory: function (){
this.set('selectedCategory',3);
}
}
});
App.MainLinksController = Ember.ObjectController.extend({
needs: "sidebarCategories",
selectedCategory: Ember.computed.alias('controllers.sidebarCategories.selectedCategory')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment