Skip to content

Commit

Permalink
Se agrega funcionalidad barrer modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Wlogzz committed Mar 12, 2023
1 parent 797bacb commit a692371
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions app/peliculas/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<td><?= $row_pelicula['descripcion']; ?></td>
<td><?= $row_pelicula['genero']; ?></td>
<td>
<img src="<?= $dir .$row_pelicula['id'].'.jpg?=n' . time(); ?>" alt="<?= $row_pelicula['nombre'];?>" width="80">
<img src="<?= $dir . $row_pelicula['id'] . '.jpg?=n' . time(); ?>" alt="<?= $row_pelicula['nombre']; ?>" width="80">
</td>
<td><?= $row_pelicula['fecha_alta']; ?></td>
<td class="text-center">
Expand Down Expand Up @@ -88,9 +88,29 @@
</div><!-- .container -->

<script>
let nuevoModal = document.getElementById('nuevoModal')
let editaModal = document.getElementById('editaModal')
let eliminaModal = document.getElementById('eliminaModal')

// Agregar puntero en el primer input del modal
nuevoModal.addEventListener('shown.bs.modal', event => {
nuevoModal.querySelector('.modal-body #nombre').focus()
})

// Función barrer modal (nuevo-edita)
nuevoModal.addEventListener('hide.bs.modal', event => {
nuevoModal.querySelector('.modal-body #nombre').value = ""
nuevoModal.querySelector('.modal-body #descripcion').value = ""
nuevoModal.querySelector('.modal-body #genero').value = ""
nuevoModal.querySelector('.modal-body #poster').value = ""
})
editaModal.addEventListener('hide.bs.modal', event => {
editaModal.querySelector('.modal-body #nombre').value = ""
editaModal.querySelector('.modal-body #descripcion').value = ""
editaModal.querySelector('.modal-body #genero').value = ""
editaModal.querySelector('.modal-body #img_poster').value = ""
})

// Función editar
editaModal.addEventListener('shown.bs.modal', event => {
let button = event.relatedTarget
Expand All @@ -117,7 +137,7 @@
inputNombre.value = data.nombre
inputDescripcion.value = data.descripcion
inputGenero.value = data.id_genero
poster.src = '<?= $dir ?>' + data.id + '<?='.jpg?=n' . time()?>';
poster.src = '<?= $dir ?>' + data.id + '<?= '.jpg?=n' . time() ?>';
}).catch(err => console.log(err))
})

Expand Down

0 comments on commit a692371

Please sign in to comment.