Dynamically change video URLs within the Lightbox window

2

Hello, my question is about dynamic video url change. When I click on a function (openlightbox) opens a lightbox window, and within that window I need to open video dynamically, today it opens a static.

I have two segments (car and motorcycle), inside each segment I have two boxes that when clicked, a thumb / image appears where, when clicked, it loads the corresponding video.

When I click on a box it opens the thumb down and when I click on the other box opens the same thumb. Clicking this thumb triggers the function that mounts the lightbox with the video. The goal is to dynamically open these videos.

'data-vehicle' is an 'attr' that identifies the selected box.

function selecionaUrl(veiculos) {
    var boxA = $(".box-veiculo[data-veiculo=A]");
    var boxB = $(".box-veiculo[data-veiculo=B]");
    if (veiculoSegmento == 'carros'){
        if (boxA == $(".box-veiculo-selected")){
            $('#video').attr("href", "https://www.youtube.com/embed/xxxxx");
            return true;    
        }
        else if (boxB == $(".box-veiculo-selected")){
            $('#video').attr("href", "https://www.youtube.com/embed/yyyyy");
            return true;    
        }

    }else if (veiculoSegmento == 'motos'){
        if (boxA == $(".box-veiculo-selected")){
            $('#video').attr("href", "https://www.youtube.com/embed/wwwww");
            return true;    
        }
        else if (boxB == $(".box-veiculo-selected")){
            $('#video').attr("href", "https://www.youtube.com/embed/zzzzz");
            return true;    
        }
    }
}

Inside the file js , the variable that mounts the lightbox and being concatenated by (vehicles):

var htmllgtbox = '<div id="" </div> ' + '<iframe ' + veiculos + '</iframe>'
    
asked by anonymous 31.10.2017 / 21:19

0 answers