Ajey
Ajey

Reputation: 8202

TinyMCE Javascript WYSIWYG editor not working with Ember js

I am trying to use TinyMCE with ember js. Code goes as follows -

<script>
        tinymce.init({selector:'textarea'});
</script>

And the textarea is inside the text/x-handlebars template as follows

<script type="text/x-handlebars" data-template-name="course/discussion">
 <textarea>Your content here.</textarea>  
</script>

With the following setup, the TinyMCE is not working.

BUT, if I place the <textarea> outside the text/x-handlebars template, it seems to be working fine.

Any pointers on how do I make TinyMCE work when the <textarea> is inside the handlebars template

Upvotes: 0

Views: 527

Answers (1)

Oliver
Oliver

Reputation: 978

Add a view and use the didInsertElement hook to set up tinymce after the template is inserted into the DOM.

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

http://emberjs.com/api/classes/Ember.View.html#event_didInsertElement

Upvotes: 1

Related Questions