lundi 7 décembre 2020

Action-text-editor-validation in rails

If in a blog I have 2 action text editors. Say one for comments and one for articles. If I wanted to handle the attachments for only of comments editor i.e. I want to pass only image in comments attachments and the article trix editor should be same. How to implement this. I used this but it is getting implemented with both editors.

comment_form

<%= form_with model: @comment do |f| %>
            <div class="class="card mb-2"">
              <div class="card-body">
            <h4><%= f.label :Comment %></h4>
              <%= f.rich_text_area :body %>
            </div>
            </div>
              <%= f.submit 'Comment', :class => 'pull-right btn-info btn-lg'%>
          <% end %>


<script type="text/javascript">
  window.addEventListener("trix-file-accept", function(event) {
  event.preventDefault()
  alert("File attachment not supported!")
})
</script>

Aucun commentaire:

Enregistrer un commentaire