AJAX Forms Integration

DemoUsing CKEditor 5 in AJAX and Turbo forms
View on GitHub

AJAX Form Example

Turbo Stream Example

Implementation

The code below demonstrates how to use CKEditor 5 with AJAX forms and Turbo Streams. Note the use of ckeditor5_lazy_javascript_tags for deferred loading. It allows loading editor to be injected after the form is submitted and the response is received.

<% content_for :head do %>
  <%= ckeditor5_lazy_javascript_tags %>
<% end %>

<%= form_with url: form_ajax_demos_path, data: { controller: "form" } do |f| %>
  <%= f.ckeditor5 :content, required: true %>
  <%= f.submit 'Save' %>
<% end %>

Additional Resources