Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor edit data-* attributes

Tags:

ckeditor

I need a solution that allows me to add/edit/remove data-* attributes on individual elements in CKEditor without manually adding it directly in the source editors?

I haven't found any config items or plugins that allow me to do this.

How do I go about doing this?

like image 836
Sinmok Avatar asked Jun 21 '26 19:06

Sinmok


1 Answers

Here is a working sample based on the example you provided.

You can add/edit/remove data attributes on elements with this:

element.data( 'extra-info', 'test' );   // Appended the attribute data-extra-info="test" to the element.
alert( element.data( 'extra-info' ) );  // 'test'
element.data( 'extra-info', false );    // Remove the data-extra-info attribute from the element.

http://docs.ckeditor.com/#!/api/CKEDITOR.dom.element-method-data

like image 121
jnoreiga Avatar answered Jun 24 '26 01:06

jnoreiga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!