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

[demo-5]Stimulusを使ったイベントによるフォーム内容チェック #12

Open
wants to merge 1 commit into
base: 4-use-websocket
Choose a base branch
from

Conversation

yakitorii
Copy link
Member

@yakitorii yakitorii commented Dec 12, 2022

やったこと

  • Stimulusを使って、フォームの内容が不十分であればSubmitイベントで警告を出してSubmitしない
    • emotions_controller.js の追加
      • targets, actionの定義
    • index.jsでemotions_controller.jsの読み込み
    • _new.html.erb で、監視したいターゲット要素にdata: {コントローラ名_target: "ターゲット名"}data: {emotions_target: "name"}data-emotions-target="name"属性となる) を追加

確認方法

  • フォームの入力を不十分なままサブミットする

image

公式ドキュメント

Stimulus Reference

Stimulus Handbook

@yakitorii yakitorii changed the base branch from main to 4-use-websocket December 12, 2022 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant