weixin_33696822 2017-01-30 16:17 采纳率: 0%
浏览 41

用Jquery获取CKEditor数据

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于下拉菜单选项关联的问题
    • ¥15 如何修改pca中的feature函数
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
    • ¥15 画两个图 python或R