vol1ura/Sat_9am_5km

View on GitHub
app/javascript/controllers/form_controller.js

Summary

Maintainability
A
0 mins
Test Coverage
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = ['input']

  submit(event) {
    event.preventDefault()
    this.element.requestSubmit()
  }

  toggleBlock(event) {
    const input = this.inputTarget.getElementsByTagName('input')[0]
    if (event.target.checked) {
      this.inputTarget.classList.add('d-none')
      input.disabled = true
    } else {
      this.inputTarget.classList.remove('d-none')
      input.disabled = false
    }
  }
}