Skip to content

Instantly share code, notes, and snippets.

@Glarregle
Last active August 14, 2017 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Glarregle/b8a4359c028a47d6b56128535ff99677 to your computer and use it in GitHub Desktop.
Save Glarregle/b8a4359c028a47d6b56128535ff99677 to your computer and use it in GitHub Desktop.
New Twiddle
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('sibling', { path: 'sibling/:some_segment' });
this.route('sibling2');
this.route('sibling3');
})
});
export default Router;
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.active {
color: red;
font-size: 20px;
}
<h1>Please navigate to: {{link-to '/parent' 'parent'}}</h1>
{{outlet}}
<br>
<br>
<h1>Parent route template</h1>
<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 'somewhere' 'parent.sibling' 'seg1'}}
{{link-to 'somewhere' 'parent.sibling' 'seg2'}}
{{link-to 'somewhere' 'parent.sibling' 'seg3'}}
{{link-to 'somewhere' 'parent.sibling' 'seg4'}}
<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