Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo Editor - Remove toolbar

I am using kendo Editor and though... I want to disable the edit toolbar. Indeed, All I want is to have the possibility to format my textarea (bold, italic...) without allowing the user to interact with my textarea neither have a toolbar which will be very confusing to a user. I want it to be displayed like a normal readonly textarea, nothing else. I tried this :

$("#output").kendoEditor();
$($('#output').data().kendoEditor.body).attr('contenteditable', false);

But it's not working. Any ideas?

Edit

I just want to have a simple textarea, I want to hide the toolbar and manipulate the content of the textarea programmatically since it is readonly.

like image 553
Hamdi Baligh Avatar asked Dec 26 '22 11:12

Hamdi Baligh


2 Answers

This works well in MVC using HTML wrappers

 @(Html.Kendo().EditorFor(m => m.Body).Tools(t => t.Clear()))
like image 169
David Avatar answered Feb 02 '23 11:02

David


If you don't want to show the toolbar define an empty tools in the KendoUI editor initialization:

$("#editor").kendoEditor({
    // Empty tools so do not display toolbar
    tools: [ ]
});

See it here http://jsfiddle.net/OnaBai/Eh6X2/

If you want to disable the edition, you should use:

// Disable edition
$(editor.body).attr('contenteditable',false);

And the following code selects all the text and converts it to bold, then deselects it.

var range = editor.createRange();
range.selectNodeContents(editor.body);
editor.selectRange(range);
editor.exec("bold");
editor.selectRange();

The full example here: http://jsfiddle.net/OnaBai/Eh6X2/3/

like image 27
OnaBai Avatar answered Feb 02 '23 09:02

OnaBai