Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to Froala text editor

I'm trying to programatically input html into Froala text editor. Based on their documentation this should work:

$(function(){
    $('#editor').editable("setHTML", "<p>My custom paragraph.</p>", false);
});

But when I reload page I only get empty space, no errors. This is binded to textarea with id #editor. If I use this code:

$(function(){
    $('#editor').editable({inlineMode : false});
});

... then everything is ok.

Does anyone knows how to programatically input html into this editor.

like image 807
Alen Avatar asked Jul 22 '14 16:07

Alen


People also ask

Is Froala editor good?

Froala WYSIWYG HTML Editor is the best rich text editor out there. It is built using the latest technologies and taking the great advantages of jQuery and HTML5 to create an outstanding editing experience.


2 Answers

To append a text use html.insert

$("#editor").froalaEditor('html.insert','<p>new text to append</p>');
like image 91
Savrige Avatar answered Sep 23 '22 12:09

Savrige


With the latest version of Froala this works fine

$("#froalaEditor")[0]["data-froala.editor"].html.set('This should work fine');
like image 22
Gvs Akhil Avatar answered Sep 21 '22 12:09

Gvs Akhil