0

I have implemented CKeditor in one of my textarea. When i use radio button to show & hide textarea on click of radio button, javascript does not work..

After removing CKEditor from textarea.. javascript works properly..

Below is the code of HTML :

Option :
<input type="radio" name="adOption" id="adOption" value="Ads" data-rule-required="true"/> Ads
&nbsp;&nbsp;
<input type="radio" name="adOption" id="adOption" value="Page Content" data-rule-required="true" checked/> Page Content

Textarea :
<textarea name="pgContent" id="pgContent" class="ckeditor" data-rule-required="true" style="width: 100%;"></textarea>

TextBox :
  <input type="text" name="adUrl" id="adUrl" class="input-xxlarge" data-rule-required="true" />

Javascript :

$(document).ready(function(){
                    $('input[type="radio"]').click(function(){
                        if($(this).attr("value")=="Ads"){
                            document.getElementById("adURL").style.display="block"
                            document.getElementById("pgCon").style.display="none"
                        }
                        if($(this).attr("value")=="Page Content"){
                            document.getElementById("adURL").style.display="none"
                            document.getElementById("pgCon").style.display="block"
                        }                           
                    });
                });     

What the issue, i m not getting. please help me for this..

Thanks in advance..

Dhawal Mhatre
  • 435
  • 2
  • 8
  • 28

1 Answers1

0

See the first paragraph of my answer to find out how CKEditor actually works and how it deals with <textarea> to which it is attached.

<textarea> remains hidden as long as editor instance exists. You should manipulate editor UI instead. Use:

CKEDITOR.instances[ 'instanceName' ].container.hide(); // also container.show()

or

CKEDITOR.instances[ 'instanceName' ].container.$.style.display = '...';

to control visibility of the editor. Also see element.setStyle method in CKEditor API.

Community
  • 1
  • 1
oleq
  • 15,697
  • 1
  • 38
  • 65