-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified Ember.RadioButtonGroup implementation #1235
Conversation
Nice implementation! But last selected button doesn't uncheck when value becomes |
Could you write a failing test case? |
Shure. test("should uncheck previous selection when new value is null", function() {
view = Ember.RadioButtonGroup.create({
value: 'option1',
name: 'testName',
template: Ember.Handlebars.compile(
'{{ view RadioButton value="option1" }}' +
'{{ view RadioButton value="option2" }}'
)
});
appendView();
Ember.run(function() {
set(view, 'value', null);
});
equal(get(view, 'value'), null, 'value should be set');
equal(view.$("[value='option1']").attr('checked'), null, 'checkbox should not be checked');
equal(view.$("[value='option2']").attr('checked'), null, 'checkbox should not be checked');
}); |
Thanks! Should be fixed now. |
Ok, much better. But now it's stop working in the browser at all :) I've send PR to your repo. |
I also realized that there is problem with 'isChecked:checked' attribute binding. At least on Chrome. I wrote the working version today, but using custom observers on |
@caligo-mentis The test you added seems to be passing :/. I think what this really needs is a fiddle. I might have time to put one together later today. |
What browser you are using?
|
I am using chrome beta. It also passed in travis (although not sure if that is working correctly) |
Please check this fiddle http://jsfiddle.net/ZPzU2/ The problem is what |
I see. I will take a pass on this today. On Tue, Aug 14, 2012 at 12:44 PM, Andrey notifications@github.com wrote:
Gordon L. Hempton |
Ok. And check my implementation http://jsfiddle.net/66QJm/ |
If your implementation passes all the tests and fixes the issue above, I say we just go with that :). Want to PR my repo? |
The issue is fixed, but I think the problem seems to be in attributeBindings. I can write more tests for RadioButtonGroup, and create PR, but if problem is in ember.js we should fix it before. On 14.08.2012, at 23:59, Gordon L. Hempton wrote:
|
@ghempton What's the status of this? |
@ghempton can you add an example of a static radio group? I mean an example where you want to display N options to the user but they don't change. EDIT: I just noticed this. I have my RadioButtonGroup bound to a controller: {{#view Inbox.FilterRadioButtonGroup valueBinding="selectedFilter"}} Should setting EDIT2: seems it's the same thing that @caligo-mentis mentioned. The |
@wagenet Status update: I've sent a PR to @ghempton repo to fix bugs. You can find it here: ghempton#2. If he does not respond in a timely fashion then I will take over this PR. |
Hey guys, sorry about not noticing this. My inbox has been swamped in github notifications. I will take a look at this today. |
@twinturbo I have merged in your PR and rebased against master. Are there any other outstanding issues with this PR? @caligo-mentis? |
@ghempton everything should be ok now. |
@ghempton Any idea why it doesn't merge cleanly? |
@wagenet not sure... it was failing before due to a deprecated jQuery feature but I fixed the tests. Looks like Travis hasn't re-run them. Any ideas? |
@ghempton It's not a test failure, it's that it can't merge automatically which means there's a merge conflict. |
@wagenet gotcha. Just rebased again, should merge cleanly now. |
|
@tchalk, how are they more complex than On Thu, Jun 6, 2013 at 2:26 PM, Paul Chavard notifications@github.comwrote:
|
@ahawkins select is a minefield. Our primitive controls need some love. |
@ahawkins they group... Speaking of wich, we do not support grouping of options in selects. |
tl;dr ember form elements are embarrassing. On Thu, Jun 6, 2013 at 2:35 PM, Paul Chavard notifications@github.comwrote:
|
+1 for releasing this as an |
I think this is for the best, providing an addon with readme + tests + travis is more accessible. It would allow the project to ge the attention it needs, and reach maturity quicker. |
+1 making this available somehow, somewhere. It's just silly that there's no way to create a radio button in Ember. It really should be a part of the core lib. |
It looks like the vote was for an add-on. If someone releases a solid add-on we can consider whether or not it's appropriate to merge into core later. |
It should be in core, no matter what the API is. We can break compat later in future versions. But we need to support that out of the box. Embarrassing... |
@guilhermeaiolfi are you volunteering? The providing an alternative implementation using new |
We actually can't just break the API. We're attempting to keep things stable and once we hit 1.0 (which will be soon), this becomes even more essential. |
Using |
I'm using the new views from the PR without any Ember.Control and it just works (the change that was needed is merged like @wagenet noted). Would be great to make this available (at least as an add-on). |
|
||
```handlebars | ||
{{#view Ember.RadioButtonGroup name="role" valueBinding="content.role"}} | ||
{{view RadioButton value="admin"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nested view has to be accessed with {{view view.RadioButton value="..."}} in the latest RC
Any updates here? |
Hello ??? Any updates here ?? |
👍 I would totally work on this, but I need to learn how to edit pull request(s). |
+1 |
@alvincrespo the correct way would be to just create a new PR |
If you submitted the PR, you can edit, but not if someone else did. |
@wagenet @alvincrespo I know you can checkout the pull request and then you could effectively "fork" the pull request and make a new one. Once you do then if you mention the new pull request here it will become "linked" |
+1 for this feature. |
Any update about this feature ? |
I pulled this code from @ghempton and updated it to extend from component, fixed up the documentation, updated the tests, and added helpers. It works great aside from the one failing test that I can't seem to hammer out; although, I see it working when I build Ember and use it in production, so I think I'm just missing something really simple. Can someone please help me pass the last test so I can re-submit this PR? This is my first attempt at working with the Ember source and the Ember Testing Suite. I really believe this should be in the core and @ghempton did an excellent job with it; I would love to help out in any way I can to make it happen. Here's my branch: https://github.com/cmkornell/ember.js/tree/radio-button-group |
I posted this on #4352 but i wanted to get some feedback on it and continue the discussion: https://www.npmjs.org/package/ember-radio-buttons Its a slightly simpler implementation than @ghempton 's but I think it should do for most cases |
This PR contains the same API as #755 but has a simper implementation.
Ember.RadioButton
can also be used independently ofEmber.RadioButtonGroup
.Also introduces Ember.Control which is a view that uses itself as its context, necessary for the
Ember.RadioButtonGroup
implementation.