2
I inform through JQUERY the link to open a video in a modal
<video width="100%" height="400" id="vid_video" controls="controls" style="padding: 0 10px 0 10px">
<!-- AQUI DENTRO VAI O <source></source> vindo do JQUERY -->
</video>
JQUERY passes the video path and name:
$('#visualizarVideo').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var vid_video = button.data('video') //captura o valor do data-video
$("#vid_video").html('<source src="../upload/'+vid_video+'" type="video/mp4"></source>' );
//vid_video recebe por exemplo video.mp4
beauty, it’s working. But I have a table with information coming from the BD by a loop, and each row of the table is a different video. If I click on a video and close right away, the next video is the same! As if jquery did not implement "data-video". I hope what I said is understandable.
Inside the loop I inform through the data-video the address.
<li><a href="#" data-video="<?php echo $videos->vid_video ?>" data-toggle="modal" data-target="#visualizarVideo" >Visualizar</a></li>
Personal thank you! :)
What you’re putting in the variable
button
?– Sam
Thank you for answering sam. Voce refers to: var vid_video = button.data('video') ? if yes, this coming inside the <li> to store where the video is.
– Joao Torres
Blz. But had to see how you are assigning value to variable
button
.– Sam
Ah understood now. sorry. I updated the code! from a look.
– Joao Torres