Search code examples
jqueryfroala

Froala setting the placeholder text after initialization


The Froala editor component has many settings available at initialisation, including the placeholder.

However, I have a case where I must change the placeholder after initialisation.

I cannot see in the API docs any method to do this. I tried looking for a method on the Froala object via console.logging() it, but there is some obscurification that makes this unclear.

I tried:

$("<selector>").froalaEditor.placeholder("new value...");

and

$("<selector>").froalaEditor.({placeholder : "new value..."});

I am not posting a working snippet because this is not a coding issue specifically, but I can do if anyone believes it would be substantially useful.

Time is pressing so I would accept a jquery solution outside the manufacturers API for now.


Solution

  • I am answering my own question based a response from Froala support, both for future readers and as a reminder for myself.

    From a case in Jan 2017 here then answer given is:

    To set an option after the editor was initialized, you would have to do it like this:

    $('.selector').data('froala.editor').opts.placeholderText = 'foobar';
    $('.selector').froalaEditor('placeholder.refresh'); 
    

    I enquired if there was a documentation page showing this technique but was advised that the recommended method is to actually erase and re-create the Froala editor instance with the required placeholder parameter. Additionally there was mention of some potential documentation showing this technique for specific cases like placeholder, which I take to mean that not all 'opts' members can be altered this way.