Project

General

Profile

Question about how to work with Stimulus in a plugin

Added by Tantic o 1 day ago

Hello,

I am working on a plugin https://github.com/tantic/redmine_asap_theme that uses Stimulus (dropdown menu, modal window, etc.). Up to version < 6.1, I imported Stimulus and my stimulus controllers, and it worked. Since version 6.1, Stimulus is directly imported into the Redmine core. So I removed my own import, and I would like to make sure that my stimulus controllers still work. Is there a specific procedure allowing plugins to use Stimulus?

I have tried several ways, but the most natural one for me was

 
/my_plugin 
 /assets 
  /javascripts 
   - application.js // with import of the controllers folder 
   /controllers 
    - my_controller.js 

In my_controller.js, I thought I could do something like that

 
import { Controller } from "@hotwired/stimulus"; 

export default class extends Controller { 
.... 
} 

But apparently, that's not enough.
Thank you in advance for your help.