Created
January 8, 2019 23:16
-
-
Save mblandfo/56e393b8e75824126273fb607385ab8c to your computer and use it in GitHub Desktop.
radio-list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
item: undefined, | |
onSelected(){}, | |
actions: { | |
onClick() { | |
this.onSelected(this); | |
} | |
}, | |
id: Ember.computed('item', function () { | |
return this.get('item').id; | |
}), | |
name: Ember.computed('item.name', function () { | |
return this.get('item').name; | |
}), | |
selected: Ember.computed('item.selected', function () { | |
return this.get('item').selected; | |
}), | |
notSelected: Ember.computed('item.selected', function () { | |
return !this.get('item').selected; | |
}), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
items: [], | |
selectedItem: undefined, | |
actions: { | |
onSelectionChanged(itemDisplay) { | |
this.get('items').forEach(item => { | |
let selected = item.id === itemDisplay.id; | |
console.log(`item.id ${item.id} itemDisplay.id ${itemDisplay.id} selected ${selected}`); | |
Ember.set(item, 'selected', selected); | |
if (selected) { | |
this.set('selectedItem', item); | |
} | |
}); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
items: [ | |
{ id:1,name: 'One' }, | |
{ id:2,name: 'Two' }, | |
{ id:3,name: 'Three' } | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.item-display { | |
cursor:pointer; | |
} | |
.item-display.selected { | |
color: green; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3", | |
"ember-truth-helpers": "2.1.0" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment