Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable AngularJS Kendo UI Editor

I have tried using k-content-editable and well as just the generic data-ng-disabled but neither of these worked. Looking at the documentation it's not even clear to me there is a way to disable the control.

like image 341
Robert Kaucher Avatar asked Feb 10 '23 20:02

Robert Kaucher


2 Answers

You can do this by creating a custom directive:

   .directive("kNgDisabled", function() {
      return {
        restrict: "A",
        link: function(scope, element, attr) {
          scope.$on("kendoWidgetCreated", function(e, widget) {
            var value = scope.$eval(attr.kNgDisabled);

            $(widget.body).attr("contenteditable", !value);

            scope.$watch(attr.kNgDisabled, function(value) {
              $(widget.body).attr("contenteditable", !value);
            });
          })
        }
      }
    });

Then use it like this:

<textarea kendo-editor k-ng-disabled="disabled"></textarea>

Here is a live demo: http://dojo.telerik.com/@korchev/AdApu

like image 180
Atanas Korchev Avatar answered Feb 19 '23 22:02

Atanas Korchev


Add following code in your Angular controller->

 var x = document.getElementById("myForm");
    x.addEventListener("focus", myFocusFunction, true);

    function myFocusFunction() {
         $($('#keFinding').data().kendoEditor.body).attr('contenteditable', false);  
    }
like image 45
SubhoM Avatar answered Feb 19 '23 23:02

SubhoM