Skip to content

Instantly share code, notes, and snippets.

@sheriffderek
Forked from Glarregle/controllers.application.js
Last active August 14, 2017 18:43
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 sheriffderek/702ab44ba8090a50cfabda353cffc599 to your computer and use it in GitHub Desktop.
Save sheriffderek/702ab44ba8090a50cfabda353cffc599 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('parent', function(){
this.route('child-a');
this.route('child-b');
})
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
willTransition() {
this.refresh();
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
a {
color: inherit;
}
a.active {
color: red;
}
<h1>/application</h1>
{{link-to 'Go to /parent' 'parent'}}
{{outlet}}
<h2>/parent</h2>
<p>When you click one of this links, all of it's siblings are styled as active, even if they produce different dynamic segments.</p>
{{link-to 'Child A' 'parent.child-a'}}
{{link-to 'Child B' 'parent.child-b'}}
<p>If you go to routes/parent and remove the snippet 'willTransition' it will work prefectly: each link will be active when they actually are equal to the dynamic segment shown in the URL</p>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment