Text Editors through AJAX

Text Editors through AJAX

by Conn Warwicker -
Number of replies: 0
Picture of Core developers Picture of Plugin developers

Reposting this here as probably better place than the text editor section.

----

I'm loading up the moodle text editor on various pages loaded through ajax, so what i'm doing is:


require_once $CFG->dirroot.'/lib/form/editor.php';

require_once $CFG->dirroot . '/lib/editorlib.php';

$editor = \editors_get_preferred_editor();

$editor->use_editor("elbpfe_{$id}_{$this->id}");

$output .= "<textarea id='elbpfe_{$id}_{$this->id}'>".$this->getValue()."</textarea>";


So I'm getting the preferred editor and applying it to the textarea field which I output, then at the end of the content I do:

global $PAGE;

$code = $PAGE->requires->get_end_code();

return $code;


And echo that out to get the javascript to actually create the texteditor.


It's working fine except for one thing, in that the strings for all the editor options (e.g. fonts, images, etc...) are not being changed from the defaults in the tinymce template.

E.g:


screenshot


So you can see that instead of things like "font family", "font size", etc.. the strings have come back as "advanced.font_size", "advanced.font_family", etc...


Does anyone know what else I need to do to sort this out?


It's not a language file thing as they work fine when loaded through a normal page, it's only when loading through AJAX, so there must be some extra function or method that needs to be called which I'm missing I would have thought...?


Cheers.


Extra screenshots:

ss


ss

Average of ratings: -