Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a custom button to the toolbar that calls a JavaScript function?

I'd like to add a button to the toolbar that calls a JavaScript function like Tada()?

Any ideas on how to add this?

like image 450
AnApprentice Avatar asked Dec 24 '09 07:12

AnApprentice


1 Answers

Also there is a nice way allowing one to add the button without creating plugin.

html:

<textarea id="container">How are you!</textarea> 

javascript:

editor = CKEDITOR.replace('container'); // bind editor  editor.addCommand("mySimpleCommand", { // create named command     exec: function(edt) {         alert(edt.getData());     } });  editor.ui.addButton('SuperButton', { // add new button and bind our command     label: "Click me",     command: 'mySimpleCommand',     toolbar: 'insert',     icon: 'https://avatars1.githubusercontent.com/u/5500999?v=2&s=16' }); 

Check out how it works here: DEMO

like image 110
MadisonTrash Avatar answered Sep 19 '22 23:09

MadisonTrash