Skip to content

Instantly share code, notes, and snippets.

@rileyhilliard
Last active February 15, 2017 01:14
Show Gist options
  • Select an option

  • Save rileyhilliard/565939b8d37b315aae854172cf007cd0 to your computer and use it in GitHub Desktop.

Select an option

Save rileyhilliard/565939b8d37b315aae854172cf007cd0 to your computer and use it in GitHub Desktop.
link-to bug
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
routes: [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
],
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('thread', { path: '/:id' });
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
willTransition(transition) {
this._super(...arguments);
// If the user wants to transition, reset and return
if (this.continueTransition) {
// reset users selection
this.continueTransition = false;
return false;
}
transition.abort();
var previousTransition = this.getWithDefault('previousTransition', transition);
this.set('previousTransition', previousTransition);
var transitionToNewRoute = confirm("Are you sure you want to navigate to a new route?");
if (transitionToNewRoute) {
this.continueTransition = true;
previousTransition.retry();
}
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.active {
background: red;
}
ul span {
display: none;
}
.active span {
display: inline;
}
ul {
list-style: none;
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<ul>
{{#each routes as |id|}}
<li>
{{#link-to
"thread"
id
data-control-name="view_message"
class="msg-conversation-listitem__link msg-conversations-container__convo-item-link"}}
Route {{id}}
<span>I am active</span>
{{/link-to}}
</li>
{{/each}}
</ul>
{{outlet}}
<br>
<br>
{
"version": "0.11.0",
"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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment