I have a function that makes a switch case to select a specific time for a certain element. The problem is that the cases are generated based on the number of elements in the database using the ID as the case number.
example:
swicth(---metodod de API de FOTORAMA -- ){
case {{image.id}}:
//assignacion de tiempos
}
I know that the expression inside the case is correct because if I do a console.log (); I see the id that is supposed to match with the cases
the problem that is does not activate any of the example of my function
dynamic code example:
$(function () {
$('.fotorama').on('fotorama:showend',function(){
console.log(fotorama.activeFrame.id);
switch(fotorama.activeFrame.id){
{% for imagen in imagenes %}
case {{ imagen.id }}:
fotorama.setOptions({
autoplay : {{ imagen.duracion }}
});
break;
{% endfor %}
default:
fotorama.setOptions({
autoplay: 2000
});
break;
}
})
});
code already generated:
$(function () {
$('.fotorama').on('fotorama:showend',function(){
console.log(fotorama.activeFrame.id);
switch(fotorama.activeFrame.id){
case 44:
fotorama.setOptions({
autoplay : 5000
});
break;
case 45:
fotorama.setOptions({
autoplay : 20000
});
break;
default:
fotorama.setOptions({
autoplay: 2000
});
break;
}
})
});
getSlides();