Answer the question
In order to leave comments, you need to log in
How to make convenient content generation through MIGX?
As before:
There is a slider on the page. When a slide changes, the content of the other block is updated.
(here is mostly pseudocode, so as not to confuse anyone with a slider and other things)
<div class="slider">
<!-- вообще, тут идёт генерация слайдов -->
<div class="slide active" id="1">
<img src="img/1.png">
</div>
<div class="slide" id="2">
<img src="img/2.png">
</div>
</div>
<div id="block"></div>
var slider = sliderInit(".slider"); // инициализируем слайдер
slider.onChangeSlide(changeBlock); // привязываем функцию
var data = {
"slides":{
"1":['elem1', 'elem2'], // здесь хранятся id-шники элементов, которые надо подгружать
"2":['elem2', 'elem3']
}
"elements":{
"elem1":{"imgPath":"img/elems/1.png"},
"elem2":{"imgPath":"img/elems/2.png"},
"elem3":{"imgPath":"img/elems/3.png"}
}
}
function changeBlock(){
selectedSlideId = $(".slide.active").attr('id');
var generatedHtml = '';
$.each(data.slides[selectedSlideId], function(){ // перебираем id-шники элементов для активного слайда
generatedHtml += "<img src=' " + data.elems[this].imgPath + " '>";
});
block.html(generatedHtml);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question