Comments (6)
@tute I wrote a custom component
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
type: 'radio',
attributeBindings: [
'type',
'name',
'value',
'checked',
'selected'
],
checked: Ember.computed('groupValue', 'value', function() {
return this.get('groupValue') === this.get('value');
}).readOnly(),
change: function() {
var value = this.get('value');
var groupValue = this.get('groupValue');
if (groupValue !== value){
this.set('groupValue', value);
this.sendAction('selected', this.get('name'), this.get('value'));
}
}
});
Template
<table class="table table-bordered table-striped">
<thead>
<th></th>
<th>Yes</th>
<th>No</th>
<th>Don't care</th>
</thead>
<tbody>
{{#each renderItems as |item|}}
<tr>
<td>{{item.question}}</td>
<td>{{#radio-button value=1 name=item.id groupValue=item.answer selected="changed"}}Yes{{/radio-button}}</td>
<td>{{#radio-button value=0 name=item.id groupValue=item.answer selected="changed"}}No{{/radio-button}}</td>
<td>{{#radio-button value=null name=item.id groupValue=item.answer selected="changed"}}Don't care{{/radio-button}}</td>
</tr>
{{/each}}
</tbody>
</table>
Controller
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
changed: function(name, value) {
// handle change
}
},
:
Hope it helps!
from ember-radio-button.
Added:
groupValue: Ember.computed('groupValue', function() {
return this.get('attributeName');
}),
to the component to fix that.
from ember-radio-button.
@hglattergotz how did you solve this issue? I'm facing it right now, and thinking how to best solve it. Thanks!
from ember-radio-button.
Thank you!
from ember-radio-button.
@hglattergotz doesn't your this.set('groupValue', value);
mutate item.answer
, violating DDAU, and presenting the same bug? Thanks!
from ember-radio-button.
Cool, thanks!
from ember-radio-button.
Related Issues (20)
- make keyboard navigable according to WCAG-A
- DEPRECATION: `hasBlock` is deprecated. Use `has-block` instead. HOT 4
- Where is Version 3 for Ember. 3.16? on EmberObserver? HOT 6
- Trying to upgrade to newer version
- multiple depreciations detected in 2.0.1
- `aria-checked` not being set on `master` branch HOT 3
- Changes on master have not yet been released HOT 22
- groupValue Documentation a bit confusing HOT 1
- Error: You cannot use `attributeBindings` on a tag-less component HOT 4
- <input> field isn't including a correct "value" attribute in the DOM in IE11
- autofocus attribute not supported HOT 1
- groupValue not updated on button deselect HOT 6
- Allow specifying a label using inline invocation HOT 3
- CRUD : Edit does not retain previous value HOT 2
- Upgrade ember-cli-htmlbars to remove deprecation warning HOT 3
- Question: What is this syntax in render of a test HOT 3
- aria-checked not used?
- Replace sendAction with closure actions HOT 10
- Remove `labeled-radio-button`
- How do I add data attributes to radio-button ? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-radio-button.