2016-03-07 35 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>

我覺得這種方式是其他人更容易理解,是對值編碼更優雅。