Creating and destroying CKEditor 3 depending on a selected radio button
I've been integrating CKEditor into Vanilla 1 forums using jQuery and I wanted to make it a little bit more intelligent. I would like to make CKEditor appear only when the "Html" formatter is selected. The formatter selection is controlled via the following code:
- <li id="CommentFormats">Format comments as
<input type="radio" class="FormatTypeRadio" value="Text" id="Radio_Text" name="FormatType">
<label class="Radio" for="Radio_Text">Text</label>
<input type="radio" class="FormatTypeRadio" checked="checked" value="Html" id="Radio_Html" name="FormatType">
<label class="Radio" for="Radio_Html">Html</label>
<input type="radio" class="FormatTypeRadio" value="BBCode" id="Radio_BBCode" name="FormatType">
<label class="Radio" for="Radio_BBCode">BBCde</label>
</li>
Using the standard CKEditor jQuery adapter I can make sure that the editor ALWAYS appears using:
- $('#CommentBox').ckeditor(config);
But when I try and get it to work from the radio buttons using the following, it never appears:
- if $('#Radio_Html').is(":checked"))
$('#CommentBox').ckeditor(config);
else
$('#CommentBox').ckeditorGet().destroy();
It doesn't matter whether "Html" is selected to begin with or not, it just never appears.
I'm a complete beginner at JS/jQuery and would appreciate any help you can give me. Thanks :)