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.
This works well in MVC using HTML wrappers
@(Html.Kendo().EditorFor(m => m.Body).Tools(t => t.Clear()))
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With