XF 2.1 [SOLVED] Using html.set on an editor instance

Riari

Member
Hi,

I'm using <xf:editor name="response" value="{$message}" /> to create an editor instance and want to be able to programmatically set the HTML after initialisation via html.set.

Using this method:

JavaScript:
!function($, window, document, _undefined)
{
    "use strict";

    XF.ResponseTest = {
        init: function(event, editor, xfEditor)
        {
            if (event.target.name != 'response_html') return;

            editor.html.set('test');
            console.log(editor.html.get());
        }
    };

    $(document).on('editor:init', XF.ResponseTest.init);
}
(jQuery, window, document);

The HTML appears to be set internally as the console.log statement shows the updated HTML, but the change is not reflected visibly and if I manually type anything into the editor, editor.html.get() still returns the markup set by editor.html.set('test') rather than the new content.

How can I make this work correctly? I've also tried acting on the editor:first-start event to no avail.

Thanks
 
False alarm! I had a Vue component initialising on a parent element and that was interfering with the editor. I initialised the component after the editor instead and was able to get it working from there.
 
Top Bottom