2013-10-27 159 views
2

试图做一个漂亮的CKEditor的在Rails 4应用干净的安装的CKEditor +轨道4安装

这种宝石https://github.com/tsechingho/ckeditor-rails

我有几个问题...

-The第一,我有一种形式的CKEditor,当我访问该表单的页面时,它只会加载一个常规的文本输入框。当我手动重新加载相同的页面时,CKEditor将加载,但只有在我重新加载页面之后。它不显示在第一页加载。
- 第二个是,CKEditor只是吐出原始的html。我相信这只是我的一个简单的错误,但我还没有遇到任何答案。

下面是相关的一切和每个宝石

指令的Gemfile
gem 'ckeditor_rails'

应用程序/资产/ Java脚本/ application.js中

//= require jquery 
//= require jquery_ujs 
//= require ckeditor-jquery 
//= require bootstrap 
//= require turbolinks 
//= require_tree . 
$('.ckeditor').ckeditor({ 
    // optional config 
}); 

应用程序/ views/posts/_form.html.erb

<div class="form-group"> 
    <%= f.label :title %> 
    <%= f.text_field :title, class: "form-control" %> 
</div> 
    <div class="form-group"> 
    <%= f.label :body %> 
    <%= f.text_area :body, class: "ckeditor" %> 
    </div> 
    <div class="form-group"> 
    <%= f.submit class: "btn btn-primary" %> 
    </div> 

这是控制台错误/警告的完整列表。所有应该来自CKeditor安装之后。

Invalid CSS property name: -webkit-overflow-scrolling style.css:3000 
Invalid CSS property value: transform 0.3s ease-out style.css:3997 
Invalid CSS property value: -webkit-linear-gradient(left, color-stop(rgba(0, 0, 0, 0.5) 0%), color-stop(rgba(0, 0, 0, 0.0001) 100%)) style.css:4331 
Invalid CSS property value: -webkit-linear-gradient(left, color-stop(rgba(0, 0, 0, 0.0001) 0%), color-stop(rgba(0, 0, 0, 0.5) 100%)) style.css:4340 
Uncaught TypeError: Cannot call method 'appendChild' of undefined ckeditor.js?body=1:74 
Uncaught The editor instance "post_body" is already attached to the provided element. 
+0

什么是你的代码添加图像。我的作品除了图片上传 –

+0

在你的application.us文件中,你包含了js代码,但没有要求自我。此外,通常建议将任何代码分离到自己的文件中,并将其包含在application.is清单文件中。 – ahnbizcad

回答

0

对于未来的Google -

看到这个Github Issue

问题是与TurboLinks干扰。事实证明,实际的页面加载不是问题,而是使用CKEditor表单指向页面的链接。解决方法是直接从包含CKEditor所在链接的div中禁用turbolink。

在我的情况下的解决方案看起来是这样的......

_header.html.erb
<ul class="nav navbar-nav pull-right" data-no-turbolink>