Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set angular-ui-tinymce editor content after navigation

I'm using angular-ui-tinymce (latest version 0.0.4, https://github.com/angular-ui/ui-tinymce/blob/master/src/tinymce.js).

I've encountered a problem I cannot solve.

On the first page load, content is loaded to the editor via ng-model. Then I navigate to another state and then navigating back to state with the editor. The value still exists on the scope (I've checked it) but the content doesn't appear in the editor for some reason I cant figure..

This is the the textarea with the directive as attribute:

<textarea rows="10" class="form-control" id="desc" ui-tinymce ng-model="valueFromScope"></textarea>

This changes happened after updating AngularJS from 1.5 to 1.2.1. I thought it had something to do with ngSanitize but I'm not sure..

btw angular-sanitize and ngSanitize are included in the app.

Any advice?

update
It seems like ngModel.$render is not doing anything.

     ngModel.$render = function() {
        console.log(ngModel);
        tinyInstance = tinymce.get(attrs.id);

      if (tinyInstance) {

        tinyInstance.setContent(ngModel.$viewValue || '');
        updateView();
      }
    };

Nothing is printed out, not even undefined, this means ngModel.$render doesn't even run. Any reasons for that?

Update
I don't think model.$render is related, from what I understand $render only executes on a programmatic change like actually editing the text and that works..

I still can't figure it out, sometimes the value is shown and sometimes not.

like image 926
Orz Avatar asked Nov 19 '13 11:11

Orz


1 Answers

Problem Solved! - for now..

Thanks to @alonisser I've found a solution.

From what I understand, the problem is occurring because something has changed in the prioritizing of angularjs directives.

read the following: http://iwang.github.io/html/angular/angularjs/2013/11/04/ngmodel-render-cannot-be-overriden-in-angular-rc3.html

the simple fix is just to add priority definition to the directive

return {
  priority: 10,
  require: 'ngModel',
like image 99
Orz Avatar answered Oct 17 '22 08:10

Orz