用Jquery获取CKEditor数据


                    

我在通过Jquery获取CKEditor值时遇到问题。 打开控制台时,我有无法读取未定义的属性'getData'</ code>。
我查看了呈现的代码,并且脚本部分在那里时ckEditor似乎没有呈现。 当我删除脚本部分时,它在HTML中呈现良好。 无论脚本是否存在,页面上的CKEditor都可以正常运行,我只看到HTML的区别。</ p>

我的代码:</ strong> </ p>

  {{form_start(form,{'id':'formCorrection'〜reponse.id})}}
{{form_widget(form.commentaire,{'id':'commentaire'〜reponse.id})}}
{{form_row(form.submit)}}
{{form_end(form)}}

<脚本>
     var idCommentaire ='commentaire {{reponse.id}}';;
     var commentaire = CKEDITOR.instances [idCommentaire] .getData();
     $(“#formCorrection {{reponse.id}}”)。submit(function(){
         $ .ajax({
             输入:“ POST”,
             网址:“ {{path('paces_colle_correctioncolleqr_sauvegardercorrectionpassage')}}”,
             数据:{commentaire:commentaire}
         })
     });
</ script>
</ code> </ pre>

带有脚本部分:</ strong> </ p>

   </ textarea>
</ code> </ pre>

没有脚本部分:</ strong> </ p>

   </ textarea>
['编辑 >
</ code> </ pre>
     </ div>

展开原文

原文

I have a problem getting CKEditor value with Jquery. When I open the console, I have Cannot read property 'getData' of undefined. I looked at the code rendered and ckEditor seem to be not rendered when the script part is there. When I remove the script part, it's rendered well in HTML. Whether the script is there or not, CKEditor is on the page and working, I only see the difference in HTML.

My code:

{{ form_start(form, {'id': 'formCorrection'~reponse.id}) }}
{{ form_widget(form.commentaire, {'id': 'commentaire'~reponse.id}) }} 
{{ form_row(form.submit) }}
{{ form_end(form) }}

<script>
    var idCommentaire = 'commentaire{{ reponse.id }}';
    var commentaire = CKEDITOR.instances[idCommentaire].getData();
    $("#formCorrection{{ reponse.id }}").submit(function() {
        $.ajax({
            type: "POST",
            url: "{{ path('paces_colle_correctioncolleqr_sauvegardercorrectionpassage') }}",
            data: {commentaire: commentaire}
        })
    });
</script>

With script part :

<textarea id="commentaire1148472" name="paces_colle_correctioncolleqr_correctionreponseqr[commentaire]" required="required" class="ckeditor"></textarea>

Without the script part :

<textarea id="commentaire1148472" name="paces_colle_correctioncolleqr_correctionreponseqr[commentaire]" class="ckeditor" style="visibility: hidden; display: none;"></textarea>
<div id="cke_commentaire1148472" class="cke_1 cke cke_reset cke_chrome cke_editor_commentaire1148472 cke_ltr cke_browser_webkit" dir="ltr" lang="fr" role="application" aria-labelledby="cke_commentaire1148472_arialbl">['ckEditor stuff']</div>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐