Skip to content

Using Trestle 0.10.0 - unable to use Stimulus controller #486

@quantavi

Description

@quantavi

Hi!

I am working on adding "Reset password" to trestle-auth provided login page. During that I have discovered that my simple controller is not being connected.

First I wanted to add this:

config.hook("auth.login.form.after") do
    content_tag(:div, data: { controller: "auth" }, class: "forgot-password-container") do
      button_tag "Forgot password?", type: "button", class: "btn btn-link forgot-password-btn", data: { action: "click->auth#forgotPassword" }
    end
  end

The auth_controller.js:

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
    connect() {
        console.log("Started")
      }
  // other code
}

Then I tried to see if I am able to load this controller at all in Trestle, so I tried adding this in one of the admin files:

col(sm: 6) { password_field :password_confirmation, data: { controller: "auth" } }

Still nothing. I was able to see data-controller="auth" in the source page for given elements, but connect was not ran.

Then I added the same controller to a main page(that is not using Trestle) and the controller connected.

Do I need to add some special configuration?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions