question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarify how to declare multi-word controller names in docs

See original GitHub issue

Just something you might want to add to the docs eventually. After some experimenting with trying to get a multi-word controller working. I eventually realized that it has to be separated by a - instead of a _ like the controller file itself needs to be named.

<div data-controller="option-panel">
  <div data-target="option-panel.widget"></div>
  <div data-action="click->option-panel#show"></div>
</div>

… which points to …

option_panel_controller.js

At first, I was putting _ in the markup data attributes before I realized it was a dash. This might be assumed by some folks, but still might not be a bad idea to mention it in the docs or in an FAQ somewhere.

I’m happy to submit a pull request for this as well but wasn’t sure where or how you’d want to include this in the handbook.

Cheers 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:22
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
christhesoulcommented, Jun 3, 2019

Hey @javan. As someone who is struggling a little with this right now, I’d love to help clarify it for other newcomers. Your link above 404s, and I’m struggling to find the right “vanilla” way of doing this.

e.g. Using without a Build System states the following:

application.register("hello", class extends Stimulus.Controller {
  static get targets() {
    return [ "name" ]
  }

  // …
})

Should the "hello" be "hello-world" or "helloWorld"? I feel like it should be helloWorld but I can only get it to work with the data-controller if it’s hello-world.

Perhaps it might be clearer if examples were two-word controllers to begin with – as it’s (arguably) easier to work backwards from two words than forwards from one?

Happy to help if I can. Thanks. 👍

3reactions
sstephensoncommented, Jan 19, 2018

Thank you for the feedback! We do have the webpack filename-to-identifier mapping documented, but I agree it’s not at all obvious. I’d like to see if we can work this into the Handbook.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clarify how to declare multi-word controller names in docs #62
After some experimenting with trying to get a multi-word controller working. I eventually realized that it has to be separated by a -...
Read more >
Keyboard shortcuts for Google Docs
Keyboard shortcuts for Google Docs ; Bold, Ctrl + b ; Italicize, Ctrl + i ; Underline, Ctrl + u ; Strikethrough, Alt...
Read more >
ESLint Vue multiword components - Stack Overflow
There's a simple solution. You need define your component name with more than one word as it states. Should be ...
Read more >
A simple sway to generate controlled documents - QbDVision
First things first, let's clarify: we use Google Docs for drafting and collaborating on our controlled documents. Our final, approved controlled ...
Read more >
10 JavaScript Naming Conventions Every Developer Should ...
1. Naming Convention for Variables. JavaScript variable names are case-sensitive. Lowercase and uppercase letters are distinct. For example, you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found