最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to hide and show a CKEditor using jQuery? - Stack Overflow

programmeradmin1浏览0评论

The following code should allow to hide/show the CKEditor form

<a onClick="$('#form1').hide();">Hide</a>
<a onClick="$('#form1').show();">Show</a>
<form action="sample_posteddata.php" method="post" id="form1">
    <textarea id="editor1" name="editor1">blabla</textarea>
    <script type="text/javascript"> CKEDITOR.replace( 'editor1' ); </script>
    <input type="submit" value="Submit" />
</form>

However, this code works fine on Chrome but on Firefox, once I have toggled once the editor (one 'hide' click followed by one 'show' click) , it becomes not editable !!

How can I make it work on every browser?

Thank you.

The following code should allow to hide/show the CKEditor form

<a onClick="$('#form1').hide();">Hide</a>
<a onClick="$('#form1').show();">Show</a>
<form action="sample_posteddata.php" method="post" id="form1">
    <textarea id="editor1" name="editor1">blabla</textarea>
    <script type="text/javascript"> CKEDITOR.replace( 'editor1' ); </script>
    <input type="submit" value="Submit" />
</form>

However, this code works fine on Chrome but on Firefox, once I have toggled once the editor (one 'hide' click followed by one 'show' click) , it becomes not editable !!

How can I make it work on every browser?

Thank you.

Share Improve this question edited Jul 16, 2010 at 23:21 fabien7474 asked Jul 16, 2010 at 23:16 fabien7474fabien7474 16.6k23 gold badges99 silver badges126 bronze badges
Add a comment  | 

7 Answers 7

Reset to default 3

Solution is:

// Hide form
CKEDITOR.instances.editor1.updateElement();
CKEDITOR.instances.editor1.destroy();
$('#form1').hide();
//Show form
CKEDITOR.replace( 'editor1', {height: "220px", skin: "v2"});
$('#form1').show();

I found an answer at http://dizkover.com/post/67/how-to-show-hide-ckeditor-using-jquery-ckeditor-tip

So basically, you have to destory the CKEditor instance first by doing the ff:

if(typeof CKEDITOR.instances['element_name'] != 'undefined') {
    CKEDITOR.instances['element_name'].updateElement();
    CKEDITOR.instances['element_name'].destroy();
}

Looks like this might help you out:

http://dev.ckeditor.com/ticket/544

In the report I linked to they show trying something like this:

if (frames[0]) {
  frames[0].FCK.EditingArea.MakeEditable();
}

It doesn't seem to have a real workaround.

See here for more info. The only solution is to wait for CKEditor new version 3.4.

<div id="container">            
    <textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
</div>
<p>
    <input type="button" value="jQuery Hide" onclick="$('#container').hide('fast');" />
    <input type="button" value="jQuery Show" onclick="$('#container').show('fast');" />
</p>

Try wrapped it in a div eg : <div id="fckz"> <form >...</form> </div> and make the hide show on the div .

$("div[id*='cke_editor']").hide();

$("div[id*='cke_editor']").show();

For my CkEditor 4

发布评论

评论列表(0)

  1. 暂无评论