This is a migrated thread and some comments may be shown as answers.

[Solved] Dyamically generated radiobutton and Firefox

1 Answer 142 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Andreas Kaech
Top achievements
Rank 1
Andreas Kaech asked on 17 Jan 2008, 10:11 AM
Hi,
by generating a template for the editor via javascript dom, a problem with radiobutton occurs:
Here is the important code-snippet:

inputControl = createNamedElement('input', 'rbA1');
inputControl.type = 'radio';
inputControl.id = 'rbA1';
inputControl.defaultChecked = 'checked'; // for IE
inputControl.checked = 'checked'; // for the others
inputControl.value = 'rb1';

function createNamedElement(type, name) {
   var element = null;
   var oDoc=editor.get_Document();
   // Try the IE way; this fails on standards-compliant browsers
   try {
      element = oDoc.createElement('<'+type+' name="'+name+'">');
   } catch (e) {
      // Non-IE browser; use canonical method to create named element
      element = oDoc.createElement(type);
      element.name = name;
   }
   return element;
}

Now my problem:
In Design-Mode (IE and Firefox), this radiobutton looks "checked", but when switching to Html-Mode, only in IE the attribute "checked" is written.
Is this a bug in the editor?
Thanks for replying,
Andreas

1 Answer, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 17 Jan 2008, 05:29 PM
Hello Andreas,

The problem is not related to the editor, rather it is a bug in the FireFox/Mozilla browser when creating a radiobutton programmatically.

To workaround the problem you should change this line:

inputControl.checked = 'checked'; // for the others

to this:

inputControl.setAttribute(

"checked", "checked");

All the best,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
Andreas Kaech
Top achievements
Rank 1
Answers by
Tervel
Telerik team
Share this question
or