angular-ui / ui-tinymce

AngularUI wrapper for TinyMCE
MIT License
487 stars 370 forks source link

Instantiate Tinymce event if id is generated with angular expression in ngRepeat #354

Open stollr opened 6 years ago

stollr commented 6 years ago

For dynamically created editors (e.g. with ngRepeat) the unique id that is generated and set to the element during linking may be overwritten, if the id is generated with an angular expression, so we have to overwrite it again.

Otherwise tinymce won't be initialized.

Here's an example:

<div ng-repeat="item in collection">
    <textarea id="foo_{{ $index }}"
              name="foo_{{ $index }}"
              ui-tinymce="{{ some_config }}"
              ng-model="item.foo">
    </textarea>
</div>

During linking of uiTinymce the id is set to something like "ui-tinymce-3". But then it replaced to something like "foo_2" and in tinymce.init() it won't find the element, because it uses the selector "#ui-tinymce-3".