cleditor pressing and disabling button with js

535 Views Asked by At

I'm trying to press and disable one of cleditor buttons in one of my textarea fields from jquery. Particullary "Show Source". I was trying to do get to button with something like this:

$(document).ready(function () {
    $('.textareaclass').cleditor.buttons.source.title = "Source";
});

But it says

Uncaught TypeError: Cannot read property 'source' of undefined

Any suggestions?

2

There are 2 best solutions below

1
On BEST ANSWER

The simplest way to personnalize the toolbar is passing parameter at the widget creation :

$("#input").cleditor({controls:"bold italic underline strikethrough subscript superscript | font size"});

Also, make sure not to confuse $("#input").cleditor(); and $.cleditor :

The first transform an element (here #input) into a cleditor. Inside parenthesis, you can add parameters. The second is a global object which carry global and more tricky parameters (add callbacks for example).

1
On

The documentation suggests you should use $('.textareaclass').cleditor(). Note the parentheses.