Skip to content

Instantly share code, notes, and snippets.

@amk221
Last active July 28, 2017 15:55
Show Gist options
  • Save amk221/93563986146cde7c19cb7e9e985f32c0 to your computer and use it in GitHub Desktop.
Save amk221/93563986146cde7c19cb7e9e985f32c0 to your computer and use it in GitHub Desktop.
New 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('foo', { path: '/foo/:topId' }, function() {
this.route('nested', { path: '/nested/:nestedId' });
});
this.route('bar', function() {
this.route('nested');
});
});
Ember.Route.reopen({
setupController() {
this._super(...arguments);
this.controllerFor('application')
.set('routeName', this.get('routeName'));
}
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
a.active {
font-weight: bold;
}
Current route: {{routeName}}
<br><br>
{{!
I have specified that the link to 'foo.index'
should be considered *current* when on 'foo.nested'
yet it does not receive the active class name, but
this works fine without route params.
}}
Does not work with params:
{{#link-to 'foo.index' 1 current-when='foo.index foo.nested'~}}
foo.index
{{~/link-to}} |
{{#link-to 'foo.nested' 1 2~}}
foo.nested
{{~/link-to}}
<br><br>
Works without params:
{{#link-to 'bar.index' current-when='bar.index bar.nested'~}}
bar.index
{{~/link-to}} |
{{#link-to 'bar.nested'~}}
bar.nested
{{~/link-to}}
<hr>
{{outlet}}
Bar
<br><br>
{{outlet}}
-> Nested
<br><br>
{{outlet}}
Foo {{model.topId}}
<br><br>
{{outlet}}
-> Nested {{model.nestedId}}
<br><br>
{{outlet}}
{
"version": "0.10.6",
"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.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment