import { Controller } from '@hotwired/stimulus'; /* * The following line makes this controller "lazy": it won't be downloaded until needed * See https://github.com/symfony/stimulus-bridge#lazy-controllers */ /* stimulusFetch: 'lazy' */ export default class extends Controller { static values = { imdbId: String }; static targets = ['list'] options = [] async connect() { await this.setOptions(); } async setOptions() { if (this.options.length === 0) { await fetch(`/torrentio/movies/${this.imdbIdValue}`) .then(res => res.text()) .then(response => { this.element.innerHTML = response; this.options = this.element.querySelectorAll('tbody tr'); }); } } listTargetConnected(target) { // console.log(target); } }