#13079 closed Bug (invalid)
There is no possibility to uncheck a radio button.
Reported by: | Artur Delura | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | |
Keywords: | Cc: |
Description
In order to check/unckeck radio buttons by code we use element.setAttribute( 'checked', 'checked' );
If we got two radio buttons and we try to check first one and then the second. We end up with two radio button which have checked="checked"
attribute. So it's not possible to check once again first item. That's because first one have already set this attribute.
The proper way to work radios is to manipulate checked
property on native DOM element. See:
HTML
<input type="radio" name="done" value="foo"> <input type="radio" name="done" value="bar">
JS
var foo = CKEDITOR.document.findOne( 'input[value="foo"]' ); var bar = CKEDITOR.document.findOne( 'input[value="bar"]' ); window.setTimeout( function() { foo.setAttribute( 'checked', true ); }, 1000 ); window.setTimeout( function() { bar.setAttribute( 'checked', true ); }, 2000 ); window.setTimeout( function() { // It won't work. foo.setAttribute( 'checked', true ); }, 3000 );
Change History (7)
comment:1 Changed 10 years ago by
Status: | new → pending |
---|
comment:2 Changed 10 years ago by
I found this bug when used CKEDITOR as an API (toolbar configurator). http://jsfiddle.net/5jyv2591/
Workaround is to operate on native element.
comment:3 Changed 10 years ago by
Ok, but where's that bug in our code? If it's toolbar configurator's bug it should be reported as toolbar configurator's bug.
comment:4 Changed 10 years ago by
Bug is in CKEditor API. I provided jsfiddle (line 14th) which shows what doesn't work.
comment:5 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
The usage is wrong. Not the API. The API sets attributes - that's all.
comment:6 Changed 10 years ago by
So how I can check first radio button? There is no straighforward solution for this. But API is public so it should be.
comment:7 Changed 10 years ago by
CKEditor's API exists for CKEditor needs. If there's no public API it means that most likely it wasn't needed. CKEditor APIs like CKEDITOR.dom.* are not meant to be a generic APIs like jQuery for instance.
I don't understand to what you're referring. Can you describe a TC that doesn't work?