If I write my code like demo 7:
for ( var i = 1; i < schedule.length; i = i + 1 ) {
var ad = schedule[i];
var pos = ad[0].lastIndexOf(".");
var lastname = ad[0].substring(pos,ad[0].length);
if (lastname.toLowerCase()===".jpg"){
var sliderFrame = document.getElementById("sliderFrame");
sliderFrame.innerHTML = '<div id="slider"><a class="lazyImage" href="' + ad[0] + '"></a></div>';
imageSlider.reload();
}else if(lastname.toLowerCase()===".mp4"){
var sliderFrame = document.getElementById("sliderFrame");
sliderFrame.innerHTML = '<div id="slider"><video preload="none" data-image="'+schedule[i-1][0]+'"data-autovideo="true"><source data-src="'+ad[0]+'" type="video/mp4" /></video></div>';
imageSlider.reload();
}
}
This does not work well and the slider only contains the last image/video because it is in a for loop, My inner HTML is not the whole slider, it contains only a image/video.
My original code works well but the only thing is the function afterSlideChange(args) never get executed.