Correct way to add className to textarea
Correct way to add className to textarea
Hi all.
I am playing with the Bootstrap 3 Editor and have discovered that the textareas need styling:
Currently I note that adding className : "form-control" to the init results in the div that Editor constructs taking that class.
"label": "Mapping Requirements",
"name": "ppp_projects.proj_mapping_needs",
"type": "textarea",
"className": "form-control"
As a workaround I am setting a delay after 'open' and adding the class manually to the named fields directly using JQuery - obviously this is a labour intensive process with multiple text areas.
setTimeout(function(){
//set the class here
},500);
Is this is the pipe line to be fixed - or do I carry on with my kludge?
Oo
This question has an accepted answers - jump to answer
Answers
The
textarea
field type has anattr
option which is used to apply attributes to the element. So what you could do is:The other option is to use the
field().node()
method immediately after the initialisation and add the required class there:$( 'textarea', editor.field( 'myField' ).node() ).addClass( 'form-control' );
.Allan
Ooooh thanks!
That was peachy!
Oo