Skip to content

Instantly share code, notes, and snippets.

@sbatson5
Last active September 19, 2016 20:34
Show Gist options
  • Save sbatson5/b8c83a5dad5a30337e6e31b7ad92b1d8 to your computer and use it in GitHub Desktop.
Save sbatson5/b8c83a5dad5a30337e6e31b7ad92b1d8 to your computer and use it in GitHub Desktop.
Input id not updating
import Ember from 'ember';
const { computed, get, set } = Ember;
export default Ember.Component.extend({
inputId: computed('index', 'todo.{course,completed}', {
get() {
return `${get(this, 'todo.course')}__${get(this, 'index')}`;
}
}),
actions: {
completeTodo() {
set(this, 'todo.complete', true);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
todos: [
{
description: 'abc',
complete: false
}, {
description: '123',
complete: false
}
],
completeTodos: Ember.computed.filterBy('todos', 'complete', true),
incompleteTodos: Ember.computed.filterBy('todos', 'complete', false)
});
import Ember from 'ember';
const { computed: { filterBy } } = Ember;
export default Ember.Controller.extend({
todos: [
{
description: 'abc',
course: 'English',
complete: false
}, {
description: '123',
course: 'English',
complete: false
}
],
completeTodos: filterBy('todos', 'complete', true),
incompleteTodos: filterBy('todos', 'complete', false)
});
import Ember from 'ember';
export default Ember.Route.extend({
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{input
type="checkbox"
id=inputId
change=(action "completeTodo")
}}
<label for="{{inputId}}">
Our id is {{inputId}}
</label>
{{#each incompleteTodos as |todo index|}}
{{checkbox-component todo=todo index=index}}
{{/each}}
{
"version": "0.10.5",
"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.8.0",
"ember-data": "2.8.0",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment