【发布时间】:2020-04-21 11:10:38
【问题描述】:
如何禁用一个字段的 action_text 附件,但启用另一个字段?
我有一个包含 2 个字段的帖子模型 - description_without_attachments 和 content_with_attachments。
模型 Post.rb:
has_rich_text :description_without_attachments
has_rich_text :content_with_attachments
我发现如果将以下代码添加到packs/application.js 可以阻止所有附件 for trix action_text:
window.addEventListener("trix-file-accept", function(event) {
event.preventDefault()
alert("File attachment not supported!")
})
但是我只想阻止某些特定字段。我想它的工作方式如下:
has_rich_text :description_without_attachments, attachments: false
【问题讨论】:
-
看起来没有人比我更关心 actiontext/trix...
标签: ruby-on-rails ruby-on-rails-6 trix actiontext