App = Ember.Application.create({});
// Create route URLs for each section
App.Router.map(function() {
this.resource('home', function(){
var routeOrder = [
'sectionOne',
'sectionTwo',
'sectionThree'
];
// Add each route
for (var i = 0, len = routeOrder.length; i < len; i++) {
this.route(routeOrder[i]);
}
App.Router.sectionOrder = routeOrder;
});
});
// Index redirects to home (this fiddle doesn't work of index route)
App.IndexRoute = Ember.Route.extend({
redirect: function(){
this.transitionTo('home');
}
});
//
// Handles navigating between sections
//
App.ApplicationRoute = Ember.Route.extend({
actions: {
// Open the next section in the order that is not complete
gotoNextStep: function(){
console.log('Goto next');
var sections = App.Router.sectionOrder;
for (var i = 0; i < sections.length; i++) {
var section = sections[i],
controller = this.controllerFor('home.'+ section);
if (controller && !controller.get('isComplete')) {
this.transitionTo('home.'+ section);
return true;
}
}
return false;
}
}
});
//
// Build home page with all sections
//
App.HomeRoute = Ember.Route.extend({
renderTemplate: function (controller, context) {
this.render();
// Build all the additional sections
var sections = App.Router.sectionOrder;
for (var i = 0; i < sections.length; i++) {
var name = sections[i],
controllerName = 'home'+ name.classify();
console.log(name);
this.render(name,
{
'outlet': name,
'into': 'home',
'controller': controllerName
});
}
},
// Move to the first section immediately
redirect:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.