簡體   English   中英

使用ajax將數據放入CKEditor字段

[英]put data into CKEditor field with ajax

我在我的項目中有一個修改實體的模式。 當我將數據放入模態時,只有CKeditor字段為空。

我已經測試了不同的解決方案,但到目前為止它們都不起作用。 我檢查了一下,我要放入CKEditor字段中的數據不為null或不存在。

謝謝您的幫助。

阿賈克斯:

function ($) {
function remplirFormSociete(modal,reponse){
    alert(reponse['INFO']);
            modal.find('input#edit_form_Id').val(reponse['Id']);
            modal.find('input#edit_form_NOM').val(reponse['NOM']);
            modal.find('select#edit_form_CATEGORIES').val(reponse['CATEGORIES']);
            modal.find('input#edit_form_INFO').val(reponse['INFO']);
            modal.find('input#edit_form_HOST').val(reponse['HOST']);
            modal.find('input#edit_form_NOM_USER').val(reponse['NOM_USER']);
            modal.find('input#edit_form_MDP').val(reponse['MDP']);
    }

    $(document).ready(function(){  

        //Lorsque l'utilisateur édit un employé temporaire
        $('#EditSociete').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget) // Button that triggered the modal
            var recipient = button.data('whatever') // Extract info from data-* attributes
            var modal = $(this);
            if(recipient){
                $.ajax({
                    url: BaseURL+"/societe/ajax/Societe",
                    method: "post",
                    data: {Id:recipient},
                    success :  function(reponse)  {
                        remplirFormSociete(modal,reponse[recipient]);
                     }
                });
            } else {
                var reponse = [];reponse['Id']='';reponse['CATEGORIES']='';reponse['INFO']='';reponse['HOST']='';reponse['NOM_USER']='';reponse['MDP']='';
                remplirFormSociete(modal,reponse);
            }
        });
    }); 
}) (jQuery);

形式:

 ->add('INFO',           CKEditorType::class, array('attr'       => array('class' => "form-control"),
                                                            'label'             => 'Information :',
                                                            'required'          => false,
                                                            'label_attr'        => array('class' => 'col-md-2 control-label')))

我認為這可以解決您的問題:

CKEDITOR.instances.editor1.setData( '<p>This is the editor data.</p>' );

參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM