fix: returns episode data on first page load

This commit is contained in:
2025-06-19 16:23:39 -05:00
parent 12aaf8e737
commit 175f4330f1
5 changed files with 70 additions and 87 deletions

View File

@@ -18,7 +18,7 @@ export default class extends Controller {
active: Boolean,
};
static targets = ['list', 'count', 'episodeSelector', 'toggleButton']
static targets = ['list', 'count', 'episodeSelector', 'toggleButton', 'listContainer']
static outlets = ['loading-icon']
options = []
@@ -35,7 +35,7 @@ export default class extends Controller {
await fetch(`/torrentio/tvshows/${this.tmdbIdValue}/${this.imdbIdValue}/${this.seasonValue}/${this.episodeValue}`)
.then(res => res.text())
.then(response => {
this.element.innerHTML = response;
this.listContainerTarget.innerHTML = response;
this.options = this.element.querySelectorAll('tbody tr');
if (this.options.length > 0) {
this.options.forEach((option) => option.querySelector('.download-btn').dataset['title'] = this.titleValue);