Question

I use a form both remotely and not remotely in different scenarios. I have a text_area in this form that I apply the css class 'ckeditor' to. If I render the form with the :remote option set to true, the text_area does not include the ckeditor. But if I do not set :remote to true, the ckeditor loads just fine.

I've looked for errors wherever I could think of to look (Network and Console tabs of Chrome Developer Tools).

Does anyone have suggestions for me to try that might lead to me being able to use the ckeditor in either case? Thanks!

Was it helpful?

Solution

I found an SO question that is a duplicate of my own. I'm not sure if I can flag it as duplicate, so I've decided to post the answer for anyone that visits this question instead of the other one in the future. If you are looking for a more detailed description of the situation, the other question's poster does a good job here.

Basically, the ckeditor needs to be instantiated upon an ajax request. My edit and new forms make an ajax request to bring up the form with the appropriate initial data, and the text_area didn't have an instance of the ckeditor attached to it. You just find the DOM object and call the ckeditor() method on it in your edit.js.erb, new.js.erb, etc. files:

$('form-...').find('.ckeditor').ckeditor();

You can also apply options to the ckeditor here. Again, see the link to the other SO question for more info.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top