Problème CKEditor append

Xidy Messages postés 87 Statut Membre -  
Xidy Messages postés 87 Statut Membre -
Bonjour,

Je crée un ckeditor (jusque là ok), ensuite je voudrais par-ci par-là en fonction de mes fonction js ajouter du texte avec couleur à l'editor

J'ai un test ici qui ne fonctionne pas :

Le problème est sans doute la façon de récupérer l'instance de ckeditor...

<textarea id="lastactions" rows="4" cols="40" style="resize: none;" readonly></textarea>
<script type="text/javascript">
//<![CDATA[
var editor =
CKEDITOR.editor.replace( 'lastactions', {
extraPlugins : 'autogrow',
autoGrow_maxHeight : 400,
removePlugins : 'resize',

toolbar: 'Custom', //makes all editors use this toolbar
toolbarStartupExpanded : false,
toolbarCanCollapse : false,
toolbar_Custom: [], //define an empty array or whatever buttons you want.
readOnly : true
});
//]]>

CKEDITOR.instances['editor'].insertText('dfsdfsdf');
</script>

Merci d'avance !

2 réponses

  1. Xidy Messages postés 87 Statut Membre 3
     
    J'ai un peu avancé, j'ai l'instance et plus d'erreurs :


    <textarea id="lastactions" rows="4" cols="40" style="resize: none;" readonly></textarea>
    <script type="text/javascript">
    //<![CDATA[
    CKEDITOR.replace( 'lastactions', {
    extraPlugins : 'autogrow',
    autoGrow_maxHeight : 400,
    removePlugins : 'resize',
    uiColor: '#BC1414',

    toolbar: 'Custom', //makes all editors use this toolbar
    toolbarStartupExpanded : false,
    toolbarCanCollapse : false,
    toolbar_Custom: [], //define an empty array or whatever buttons you want.
    readOnly : true
    });
    //]]>

    var editor = CKEDITOR.instances.lastactions;
    editor.insertText('some text here');
    editor.insertHtml( "WTF!" );
    </script>



    Par contre le texte en append (2 façon testées) ne marche pas que ce soit avec insertText ou insertHtml
    0
  2. Xidy Messages postés 87 Statut Membre 3
     
    J'ai réussi de cette façon


    <script type="text/javascript">
    //<![CDATA[
    CKEDITOR.replace( 'lastactions', {
    extraPlugins : 'autogrow',
    autoGrow_maxHeight : 400,
    removePlugins : 'resize',
    uiColor: '#BC1414',

    toolbar: 'Custom', //makes all editors use this toolbar
    toolbarStartupExpanded : false,
    toolbarCanCollapse : false,
    toolbar_Custom: [], //define an empty array or whatever buttons you want.
    readOnly : true
    });
    //]]>

    var editor = CKEDITOR.instances.lastactions;
    //editor.setData(CKEDITOR.instances['lastactions'].getData()+"fggdf");
    </script>


    Mais je ne vois pas pourquoi insertText et insertHtml ne fonctionnent pas...
    0