a11yist/app/javascript/controllers/check_link_controller.js

17 lines
434 B
JavaScript
Raw Permalink Normal View History

2024-07-26 00:59:00 +02:00
import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="check-link"
export default class extends Controller {
static targets = ["input", "button"]
connect() {
this.inputTarget.addEventListener("input", e => this.onUrlInputChange(e))
}
onUrlInputChange(event) {
this.buttonTarget.href = this.inputTarget.value;
this.buttonTarget.innerHTML = this.inputTarget.value;
return true;
}
}