javascript - change ckeditor toolbar from attribute in textarea? -


i using ckeditor jquery adapter plugin , im wondering how can simplify process , select different toolbar dynamically attribute within textarea tag.

<textarea class="form-control ckeditor" data-toolbar="web"></textarea>  <script>   $('textarea.ckeditor').ckeditor({   height : '100px',   width : '100%',   toolbar : $(this).attr('data-toolbar'),   allowedcontent : true    }); </script> 

in case have toolbar called "web" , configured in config file , figure nicer code if had control on toolbars using data- attribute. way can have different toolbars on multiple editors on page.

any ideas on how can via attribute without having write additional code ?

you can set toolbar configuration each editor instance handling instancecreated event. new editor instance passed in event data give access textarea element editor instance attached , allow use value of data-toolbar attribute toolbar configuration.

<script>     ckeditor.on('instancecreated', function(evt) {        evt.editor.config.toolbar = evt.editor.element.$.getattribute('data-toolbar');     }); </script> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -