angular-trix icon indicating copy to clipboard operation
angular-trix copied to clipboard

Trix-editor ng-model binding not working inside ui.bootstrap modal

Open govind1246 opened this issue 8 years ago • 4 comments

Observing an extremely odd behavior while using angular-trix inside an ui.bootstrap modal. Inside modal html template if "trix-editor" element is wrapped inside a div then ng-model binding doesn't work, having said that it seems to be working fine if there is no parent div. Please take a look at plunker link for the same: http://plnkr.co/edit/C4BTOHLoXV55lXDJ1tKh?p=preview.

After putting debugger in angular-trix.js i could observe that inside following code blob:

ngModel.$render = function() {   
     if (element[0].editor) {
          element[0].editor.loadHTML(ngModel.$modelValue);
     }
....

value of element[0]:

  1. trix-editor when there is no parent div.
  2. trix-toolbar when there is parent div.

Probably this is the reason ng-model is not working inside div, not sure why element[0] would return different result inside bootstrap modal.

govind1246 avatar Feb 05 '17 20:02 govind1246

Experiencing this as well. The trix-change event won't trigger as a result, nor will any custom validators.

jzlosman avatar Mar 23 '17 15:03 jzlosman

By adding ng-if="true" to the element resolves the issue

Here is the solution https://github.com/sachinchoolur/angular-trix/issues/17#issuecomment-234251541

jinnabaalu avatar Apr 12 '17 15:04 jinnabaalu

This solution worked.

ibnYusrat avatar Sep 26 '17 12:09 ibnYusrat

Haha WTF, this helped me too. Thank you! You just saved me a computer, was really near of throwing it out the window ;)

tjet-lw avatar Aug 23 '18 05:08 tjet-lw