Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

A delay in setting the model will cause tinymce to remain empty #49

Closed
honeyd opened this issue Oct 23, 2013 · 6 comments
Closed

A delay in setting the model will cause tinymce to remain empty #49

honeyd opened this issue Oct 23, 2013 · 6 comments

Comments

@honeyd
Copy link
Contributor

honeyd commented Oct 23, 2013

Here is a Plunker to demonstrate the issue: http://plnkr.co/edit/D1UFaF

I have put a timeout around setting the model that contains the content that should display in tinymce. As you can see in the Plunker, the regular 'ol textarea eventually loads up, but tinymce does not.

I'm using AngularJS 1.2.0-rc3, and the latest version of tinymce (4.0.8 at this moment).

@honeyd
Copy link
Contributor Author

honeyd commented Oct 24, 2013

I verified this morning that this is a problem specific to AngularJS 1.2.0-rc3. Everything works great in AngularJS 1.2.0-rc2. Someone has already submitted an issue to AngularJS. Essentially, ngModel.$render is not successfully reassigned in the directive.

angular/angular.js#4560

@integry
Copy link

integry commented Oct 26, 2013

I got around this issue by adding this code:

var stopWatch = scope.$watch(attrs.ngModel, function(newValue)
{
    if (!tinyInstance) 
    {
        tinyInstance = tinymce.get(attrs.id);
    }

    if (tinyInstance) 
    {
        tinyInstance.setContent(newValue);
        stopWatch();
    }
});

before

ngModel.$render = function() {

@iwang
Copy link

iwang commented Nov 4, 2013

A simple fix is to add a positive priority in tinymce directive. In case you want to know more
http://iwang.github.io/html/angular/angularjs/2013/11/04/ngmodel-render-cannot-be-overriden-in-angular-rc3.html

@jamesfm
Copy link

jamesfm commented Nov 7, 2013

The priority fix clearly documented by @iwang worked like a dream. Genius!

@wesleycho
Copy link
Contributor

This looks like it is now fixed in master - let me know otherwise.

@JohannMarx
Copy link

iWang's solution worked for me too - thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants