Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a placeholder attribute to an instance of CKEditor?

Right now, using Alfonso's plugin, I'm able to add the placeholder attribute in config.js. However, since I'm adding into config.js, that means all instances will have the same placeholder text, right?

Well, I don't want all instances of my ckeditor to have the same placeholder text because I also noticed he also said :

The value can be set in the configuration or as an attribute of the replaced element

I figured this means that we can put "Type something..." as placeholder text for ckeditor1 and "Blabla..." as placeholder text for ckeditor2. How do I do that? Or that's not what he meant?

I have tried several ways including

    var ckeditor = CKEDITOR.replace('ckeditor1');
    ckeditor.placeholder = 'Type sometheing....';

and

    var config = [];
    config['placeholder'] = 'some value'; //or config = [{placeholder:'some value'}]
    CKEDITOR.replace("myeditor" , config );

inside that particular page but to no avail... I've also cleared my cache.

like image 872
John Evans Solachuk Avatar asked Dec 24 '22 23:12

John Evans Solachuk


1 Answers

By an attribute I meant:

<textarea name="editor" placeholder="Type here..."></textarea>

with regards to your other approaches, the configuration is an object, so this should work:

var config = {};
config.placeholder = 'some value'; 
CKEDITOR.replace("myeditor" , config );
like image 71
AlfonsoML Avatar answered Dec 27 '22 12:12

AlfonsoML