Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: How to customize data- attribute names? #124

Closed
elquimista opened this issue Mar 12, 2018 · 1 comment
Closed

QUESTION: How to customize data- attribute names? #124

elquimista opened this issue Mar 12, 2018 · 1 comment

Comments

@elquimista
Copy link

elquimista commented Mar 12, 2018

When I try to use other third party JS library (datepicker), stimulus complains. The datepicker library was using data-action attribute internally for dynamically generated DOM elements and I was using data-controller for body tag myself. What is the proper way to customize stimulus' data- attribute names, in order to avoid this name conflict?

data-controller
data-action
data-target
...

I think I saw it somewhere before, but can't remember now, tried to search but no luck.

Please let me know and can we document it in the stimulusjs.org?

@sstephenson
Copy link
Contributor

We don’t recommend changing the attribute names, but if you must, you can pass a Schema as the second argument to the Application constructor:

const application = new Application(document.documentElement, {
  controllerAttribute: "data-controller",
  actionAttribute: "data-action"
  targetAttribute: "data-target"
})
// ...
application.start()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants