stimulus-shortcut icon indicating copy to clipboard operation
stimulus-shortcut copied to clipboard

Unable to run the example

Open Amval opened this issue 4 years ago • 3 comments

Hello, I haven't been able to run this example. I have been able to run stimulus-hotkeys without issue. This is what my controllers/index.jslooks like.

// Load all the controllers within this directory and all subdirectories. 
// Controller files must be named *_controller.js.

import { Application } from "stimulus"
import Shortcut from 'stimulus-shortcut'
import Hotkeys from 'stimulus-hotkeys'

import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("controllers", true, /_controller\.js$/)
application.load(definitionsFromContext(context))

application.register('shortcut', Shortcut)
application.register('hotkeys', Hotkeys)

And on a view template:

<a href="my_route" data-controller="shortcut" data-shortcut-key-value="p">Type 'p' to activate me!</a>

I am using Rails 6.0.3 and Stimulus 2 (the preview before, and just updated it to the new release without anything changing.

Am I missing something? Thanks in advance!

Amval avatar Jan 01 '21 10:01 Amval

same issue

MohamedTaha123 avatar Jan 25 '21 18:01 MohamedTaha123

Same for me, did anyone manage to solve it? @Amval @MohamedTaha123 ? Thanks

elalemanyo avatar Nov 07 '22 11:11 elalemanyo

Still not working. I checked with a brand-new project, and this project is broken (at least with how you're told to use it.)

I used the stimulus-starter project from the Stimulus handbook to create this Glitch project. Then I followed the instructions in the README exactly, and it's not working. You can check out that glitch project to see if I did anything wrong. Hitting the letter "p" should submit the form, and you should see a console log, but there's nothing.

judy avatar Dec 29 '22 16:12 judy