cyclomarc
cyclomarc

Reputation: 2012

Ember and TinyMCE

I want to use the TinyMCE component in an Ember app. My basic question is: how and where can you init the tinymce ?

Template contains the textarea element:

<textarea class='test' name="content" style="width:100%">

I need to init TinyMce as follows:

tinymce.init({
    selector: "textarea"
});

Where do I need to do the init and how ? In think in the controller init, but this does not work as expected ...

App.IndexController = Ember.Controller.extend({
    init: function() {
        tinymce.init({
            selector: "textarea"
        });
    }    
});

See JSFiddle: http://jsfiddle.net/cyclomarc/wtktK/6/

Hope somebody can help ...

Upvotes: 2

Views: 800

Answers (1)

chrmod
chrmod

Reputation: 1445

Before tinymce.init you must make sure that your textarea tag is in DOM. On the time your controller gets initialized your view (in this case IndexView) is not yet rendered. A valid way to wait for a view be be rendered is to use didInsertElement hook in that view. In your case:

App.IndexView = Ember.View.extend({
    didInsertElement: function(){
        tinymce.init({
            selector: "textarea"
        });
    }
});

Upvotes: 5

Related Questions