2016-03-07 23 views
1

我的项目使用tinymce文本编辑器以及angularJS框架。我得到了来自https://github.com/angular-ui/ui-tinymce的指令,我可以用GitHub提供的示例将编辑器连接到TinyMce!AngularJS TinyMCE textarea关注Click事件

我对文本编辑器没有任何问题,我可以从文本编辑器的模型中检索内容,并使用数据库中的值更新模型。一切正常,直到最近我发现我不能把重点放在文本编辑器上!

我可以在点击事件时将焦点放在文本区域上的焦点指令,它在我删除tinymce引用时起作用。但是我不能把焦点放在点击事件的编辑器上。 请帮忙!

我发现FIX

添加element.append(scope.chartInstance.generateLegend()); 到$ scope.watch

回答

2

实际上,您可以在tinymce选项上设置焦点和模糊事件。以下是例子:

angular.module('MyApp', ['ui.tinymce']) 
 
.controller('MainCtrl', function() { 
 
    var ctrl = this; 
 
    ctrl.tinymceOptions = { 
 
    setup: funtion (editor) { 
 
     editor.on("focus", function() { 
 
     ctrl.showTips = true; 
 
     }); 
 
     editor.on("blur", function() { 
 
     ctrl.showTips = false; 
 
     }); 
 
    } 
 
    } 
 
});
<body ng-app="MyApp"> 
 
    <form ng-controller="MainCtrl as ctrl"> 
 
    <textarea ui-tinymce="ctrl.tinymceOptions" ng-model="ctrl.tinymceInput"></textarea> 
 

 
    <div ng-show="ctrl.showTips"> 
 
     <p>Some tips here...</p> 
 
    </div> 
 
    </form> 
 
</body>

我觉得这种方式是其他人更容易理解,是对值编码更优雅。