使用CKEDITOR.replace()方法用CKEditor

时间:2015-05-04 07:59:28

标签: javascript ckeditor

< p>我已经关注了这个主题:< / p> <醇> < li>< a href =" https://stackoverflow.com/questions/12842585/how-to-open-reply-form-under-comments-div">如何打开回复表单在评论div下< / a&gt ;; < /锂> < li>< a href =" https://stackoverflow.com/questions/15382622/ck-editor-is-not-working-after-putting-it-in-innerhtml-to-replace-a在使用Ckeditor textarea< / a&gt < /锂> < li>< a href =" https://stackoverflow.com/questions/27261108/ckeditor-with-multible-dynamic-textareas"> CKeditor with multible dynamic textareas< / a>< /立GT; < /醇> < p>作为构建简单博客评论应用程序的基础。简单的HTMl布局如下所示:< / p> < p>我正在使用jQuery .toggle()函数隐藏,用jQuery显示隐藏的评论表单。< / p> < p>我也在使用parent(); children()和next()jquery方法遍历DOM并选择显示形式的textarea元素,以便分配' name属性'对它。< / p> < p>然后我希望用CKEditor实例替换动态(textarea name =" content")。< / p> < p>但是,当我切换评论表单时,(名称="内容")属性被分配,但出现的是一个简单的textarea而没有启用ckeditor。< / p> < p>如何使每个新动态创建的textareas使用CKeditor?< / p> < p>< strong>请注意,当我硬编码名称='内容'将属性值对分配到任何文本区域中,将textarea转换为富文本编辑器。< / strong>< / p> <预><代码> < DIV>                   < DIV>                     这里有一些消息                    < / DIV>                    < div style =" height:10px;"> < a class ="回复" ID =" myHeader1" HREF ="的javascript:showonlyone(' newboxes1');" >答复和LT; / A>< / DIV>                 < / DIV>                 < div class =" replymsgbox" ID =" newboxes1">                     < form id =" frmComment" NOVALIDATE =" NOVALIDATE"方法=" POST"名称=" frmComment">                         < textarea id =" comment_text"类="">< / textarea的>                     < /形式>                 < / DIV>                 < DIV>                   < DIV>                     这里有一些消息                    < / DIV>                   < div style =" height:10px;"> < a class ="回复" ID =" myHeader2" HREF ="的javascript:showonlyone(' newboxes2');" >答复和LT; / A>< / DIV>                 < / DIV>                 < div class =" replymsgbox" ID =" newboxes2">                     < form id =" frmComment" NOVALIDATE =" NOVALIDATE"方法=" POST"名称=" frmComment">                         < textarea id =" comment_text"类="" >< / textarea的>                     < /形式>                 < / DIV> < /代码>< /预> < p>< strong> #Assign name属性并切换评论表单< / strong>< hr>< / p> <预><代码> < script src =" views / js / jquery-1.11.2.min.js"类型="文本/ JavaScript的">< /脚本>                 < script type =" text / javascript">                 function showonlyone(thechosenone){                      $(' .replymsgbox')。each(function(index){                           if($(this).attr(" id")== thechosenone){                                $(本).show(200);                           }                           其他{                                $(本).hide(600);                           }                      });                 }                 < /脚本>                 < script type =" text / javascript">                 $(' a.reply')。on("点击",功能(e){                  $(本).parent(" DIV&#34)亲本。(" DIV&#34)。下一个(" DIV&#34)。儿童('形式&#39 ;)。儿童(' textarea')。attr(" name"," content");                 });                 < /脚本> < /代码>< /预> < p>< strong>#将CKEditor添加到我的网页< / strong> < HR>< / p为H. <预><代码> < script src =" libraries / ckeditor / ckeditor.js">< / script>                 < script type =" text / javascript">                 $(document).ready(function(){                     如果(CKEDITOR)                     {                         //替换< textarea name =" content">使用CKEditor实例。                         CKEDITOR.replace('内容&#39);                     }                 });                 < /脚本> < /代码>< /预>

0 个答案:

没有答案