---
title: TinyMCE not working on page loaded by turbo
url: https://calvin.my/posts/tinymce-not-working-on-page-loaded-by-turbo
published: 2024-06-25
updated: 2026-09-17
category: Development
tags:
- Rails
- Turbo
- Javascript
- Stimulus
- TinyMCE
summary: TinyMCE may fail to activate on pages rendered through Turbo because a one-time page-load initialization does not run during Turbo-driven navigation. The post recommends moving editor setup into a Stimulus controller, where lifecycle hooks initialize the editor when its view connects and remove it when the view disconnects. Attaching the controller to the editor’s container ensures TinyMCE follows Turbo’s dynamic page lifecycle rather than leaving a plain textarea.
---

# TinyMCE not working on page loaded by turbo

TinyMCE editor is initialized once on page load. However, if there interaction is managed by Turbo, the initialization is not executed, causing the textarea to remain as a plain textarea.

To properly use TinyMCE with turbo, the initialization code is migrated into a Stimulus controller.

```javascript
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
    connect() {
        tinymce.init({});
    }
    disconnect() {
        tinymce.remove();
    }
}
```

And in your view:

```markup
<div data-controller="editor">
    <!-- your Textarea -->
</div>
```

This ties the initiation code with the connect/disconnect event from this view.
