ruby-on-rails - Rails 如何在 textarea 上禁用 tinymce?

标签 ruby-on-rails ruby ruby-on-rails-3 tinymce

我制作的每个 text_area 都有微型 mce 编辑器。

如何在某些文本区域字段上禁用 tinymce 编辑器?

我已遵循此安装指南。 https://github.com/kete/tiny_mce

我的 Controller :

class Admin::KategorisController < Admin::AdminController
  uses_tiny_mce(:options => {  :theme => 'simple'}, :editor_selector => 'mceEditor')
end

我的部分表格:

<%= f.input :name, :label => 'Navn' %>
<%= f.input :title, :label => 'URL titel' %>
<%= f.input :keywords, :label => 'Keywords' %>
<%= f..text_area :meta :cols => 80, :rows => 20, :label => 'META', :class => 'asdasd' %>
<%= f.text_area :text, :cols => 80, :rows => 20 %>

meta和text都是view中的tinymce编辑器

如果我在 Controller 中使用它:

  uses_tiny_mce(:options => {  :theme => 'simple', :class => "mceEditor"})

我收到这个错误:

TinyMCE::TinyMCEInvalidOption in Admin/kategoris#edit

Showing C:/Rails/konkurranceportalen/app/views/layouts/admin.erb where line #11 raised:

Invalid option class passed to tinymce

Extracted source (around line #11):

8:   <%= javascript_include_tag :defaults %>
9:   <%= javascript_include_tag "Highcharts" %>
10:     <%= javascript_include_tag :all %>
11:  <%= include_tiny_mce_if_needed %>
12:  <script type="text/javascript">
13: tinyMCE.init({
14:         height : "50px"

最佳答案

Tinymce 只出现在你告诉它出现的地方,即如果你保留默认配置,类是 mceEditor 的地方。

所以只需更改文本区域的类别即可。

编辑:

仔细看看从文档中获取的内容:

然后将以下内容附加到要转换为 TinyMCE 编辑器的文本区域。您可以通过在 Controller 代码选项中编辑“editor_selector”参数来更改要使用的类的名称。

:class => "mceEditor"

编辑2:

只需将其保存在您的 Controller 中

  uses_tiny_mce :options => {  :theme => 'simple', :editor_selector => 'mceEditor'}

关于ruby-on-rails - Rails 如何在 textarea 上禁用 tinymce?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5783146/

相关文章:

ruby-on-rails - Haml if else 嵌套

ruby-on-rails - 如果日期等于今天或将来的日期,则从 postgres 呈现事件

mysql - 与多对多的关系

ruby-on-rails - 如何使用 find_by 请求而不是所有操作的 ID 自定义 ActiveAdmin

ruby - 避免 rails 中的 n+1 查询错误有很多关联

ruby-on-rails - pry gem 如何重新加载?

ruby-on-rails - 是否可以让 Capistrano 通过反向 SSH 隧道进行结帐?

javascript - $( 文档 ).on ('turbolinks:load' , function() { 不起作用

ruby-on-rails - rails : How to make Date strftime aware of the default locale?

ruby-on-rails - 使用 curl 测试 Rails 路由