问题
I'm trying to embedd a ckeditor into a form and it just comes up blank. The text area is just an empty space where I expect to find an html editor window. I have a model where I want the "description" field to be html text. I thought it would be convenient to use ckeditor to edit it. I can't work out why the text field editor is not showing.
I've got a rails 3.1 app, and I'm using the ckeditor gem (version 3.6.2). I've downloaded ckeditor and put it in my assets/javascripts folder.
In my application.html.erb file I have this line:
<%= javascript_include_tag "ckeditor/ckeditor.js" %>
In my view I have some code like this:
<%= form_for(@k) do |f| %>
<%= f.cktext_area :description, :toolbar => 'Full', :width => 800, :height => 400 %>
This generates html like this:
<textarea id="k_description" rows="20" name="k[description]" cols="40" style="visibility: hidden;"></textarea>
<script type="text/javascript">
//<![CDATA[
if (CKEDITOR.instances['k_description']) {CKEDITOR.remove(CKEDITOR.instances['k_description']);}CKEDITOR.replace('k_description', { height: 400,language: 'en',toolbar: 'Full',width: 800 });
//]]>
</script>
It all looks like it should work, but it doesn't. What am I missing?
回答1:
Because of the way CKeditor links its dependancies you'll have to move it to the public folder. There is a helper option coming in Rails 3.1.1 which I believe will fix this problem. (:digest => false).
来源:https://stackoverflow.com/questions/7635388/ckeditor-text-area-is-blank-in-rails-3-1-app