0

私はwirisプラグインでckeditorを持っていますが、ユーザがck-editorの任意のインスタンスで任意のwiris質問を投稿すると、 ck-editorの3インスタンスがng-repeatであれば、ユーザはwirisの式を使ってck-editorの2番目のインスタンスを投稿し、その投稿はck-editorの2番目のインスタンスのみに表示されます。第1の例。 私のhtmlのJSAngularjs複数のckEditorsは同じngModelを持っています

app.directive('ckEditor', function() { 
     return { 
      require: '?ngModel', 
      link: function(scope, elm, attr, ngModel) { 
       var ck = CKEDITOR.replace(elm[0]); 

       if (!ngModel) return; 

       ck.on('instanceReady', function() { 
        ck.setData(ngModel.$viewValue); 
       }); 

       function updateModel() { 
        scope.$apply(function() { 
         ngModel.$setViewValue(ck.getData()); 
        }); 
       } 

       ck.on('change', updateModel); 
       ck.on('focus', updateModel); 
       ck.on('key', updateModel); 
       ck.on('dataReady', updateModel); 

       ngModel.$render = function(value) { 
        ck.setData(ngModel.$viewValue); 
       }; 
      } 
     }; 
    }); 

 <div ng-repeat="item in items"> 
<form role="form" name="DiscussionForm" novalidate> 
      <input type="text" name="followup" ng-model="followupDis" 
    ck-editor placeholder="Compose" required> 
      <div><button type="submit"ng-click="start()">Post</button> 
      </div> 
     </form> 
</div> 

私はそれを変更する必要がありますので、私は最初の要素var ck = CKEDITOR.replace(elm[0]);のインスタンスを作成しているディレクティブに期待しています。 したがって、ckeditorの複数のインスタンスのソリューションをwirisと共有することができます。

答えて

0

私はこれを解決できる属性のIDを変更して見つけました。 jsの中

app.directive('ckEditor', function() { 
     var counter = 0, prefix = "followupDiscussionPostReply-"; 
     return { 
      require: '?ngModel', 
      link: function(scope, elm, attr, ngModel) { 

       if (!attr.id) { 
        attr.$set('id', prefix + (++counter)); 
       } 
       // rest of the code 

これらの変更は、複数のckeditorsが私のために同じngModelの問題を持って固定しました。

関連する問題