0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Stimulus ファイルネストのdata属性の書き方

Posted at

ここでは通常のhtmlとslimでの使い方に止めます

想定ファイル構造

app/
└── javascript/
    └── controllers/
        └── greeting/
            └── english_controller.js

通常のhtmlファイル

<div data-controller="greeting--english" data-greeting--english-target="hello"></div>

slimファイル

/ 通常
div data-controller="greeting--english" data-greeting--english-target="hello"

/ railsのlink_toメソッドを使う場合
= link_to "Home", root_path, data: { controller: "greeting--english", greeting__english_target: "hello" }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?