Подключен fancybox3.
Вызов модального окна с загрузкой контента:
<div class="avatar avatar__hover-menu js-avatar-singup" data-fancybox data-type="ajax" data-src="modal.html" data-filter="#modal-signup">
Есть файл modal.html в котором код модального окна.
При клике открывается модальное окно, но не инициализируется слайдер slick и его стили.
Из за чего такое может происходить, куда копать?
Вот код:
Код при клике на кнопку:
<div class="avatar avatar__hover-menu js-avatar-singup" data-fancybox data-type="ajax" data-src="modal.html" data-filter="#modal-signup">
Код модального окна:
<!-- modal-slider -->
<div id="modal" class="modal" style="display: none;">
<div class="modal__container">
<div class="modal__right">
<div class="avatar avatar--modal">
<div class="avatar__wrap-img">
<img class="avatar__img lazy"
src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="img/Tom.png" alt="">
<svg class="icon republican-elefant">
<use xlink:href="img/sprite-icon.svg#republican-star"></use>
</svg>
</div>
<div class="avatar__wrap-name">
<div class="avatar__name">Tom Smith</div>
<p>Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</p>
</div>
<a href="#" class="button button--follow">Follow</a>
</div>
<div class="modal__content">
<p>Lorem, ipsum dolor. Lorem, ipsum dolor.</p>
<div class="modal__slider-main">
<div class="modal__slide" data-index="1">
<img src="img/view2.jpg" alt="">
</div>
<div class="modal__slide" data-index="1">
<img src="img/view3.jpg" alt="">
</div>
<div class="modal__slide" data-index="1">
<img src="img/view4.jpg" alt="">
</div>
<div class="modal__slide" data-index="1">
<img src="img/view5.jpg" alt="">
</div>
<div class="modal__slide" data-index="1">
<img src="img/view6.jpg" alt="">
</div>
<div class="modal__slide" data-index="1">
<img src="img/view7.jpg" alt="">
</div>
</div>
<div class="modal__slider-nav">
<div class="modal__slide">
<img src="img/view2.jpg" alt="">
</div>
<div class="modal__slide">
<img src="img/view3.jpg" alt="">
</div>
<div class="modal__slide">
<img src="img/view4.jpg" alt="">
</div>
<div class="modal__slide">
<img src="img/view5.jpg" alt="">
</div>
<div class="modal__slide">
<img src="img/view6.jpg" alt="">
</div>
<div class="modal__slide">
<img src="img/view7.jpg" alt="">
</div>
</div>
<div class="modal__bottom">
<div class="view">
<svg class="icon icon_view">
<use xlink:href="img/sprite-icon.svg#view"></use>
</svg>
<span>123</span>
</div>
<div class="controls--modal">
<div class="controls-arrows--modal">
<div class="controls-dots--modal"></div>
</div>
</div>
</div>
</div>
</div>
<div class="modal__left">
<div class="modal__left-top">
<div class="comment">
<svg class="icon icon_view">
<use xlink:href="img/sprite-icon.svg#comments"></use>
</svg>
<span>23</span>
</div>
<ul class="modal__social">
<li>
<a href="">
<img src="img/facebook.png" alt="">
</a>
</li>
<li>
<a href="">
<img src="img/google.png" alt="">
</a>
</li>
<li>
<a href="">
<img src="img/twitter.png" alt="">
</a>
</li>
</ul>
</div>
<div class="people-chat">
<ul class="people-chat__items">
<li class="people-chat__item">
<div class="avatar avatar--list">
<div class="avatar__wrap-img">
<img class="avatar__img lazy"
src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="img/hanna.png" alt="">
<svg class="icon democratic-donkey">
<use xlink:href="img/sprite-icon.svg#democratic-star"></use>
</svg>
</div>
<div class="avatar__wrap-name">
<div class="avatar__name">Hanna Smith</div>
<div class="chat chat-d">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
</div>
</div>
</li>
<li class="people-chat__item">
<div class="avatar avatar--list">
<div class="avatar__wrap-img">
<img class="avatar__img lazy"
src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="img/Tom.png" alt="">
<svg class="icon democratic-donkey">
<use xlink:href="img/sprite-icon.svg#democratic-star"></use>
</svg>
</div>
<div class="avatar__wrap-name">
<div class="avatar__name">Tom Smith</div>
<div class="chat chat-r">Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>
</div>
</div>
</li>
<li class="people-chat__item">
<div class="avatar avatar--list">
<div class="avatar__wrap-img">
<img class="avatar__img lazy"
src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="img/harry.png" alt="">
<svg class="icon republican-elefant">
<use xlink:href="img/sprite-icon.svg#republican-star"></use>
</svg>
</div>
<div class="avatar__wrap-name">
<div class="avatar__name">Harry Smith</div>
<div class="chat chat-i">Lorem ipsum Lorem ipsum</div>
</div>
</div>
</li>
<li class="people-chat__item">
<div class="avatar avatar--list">
<div class="avatar__wrap-img">
<img class="avatar__img lazy"
src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="img/addam.png" alt="">
<svg class="icon republican-elefant">
<use xlink:href="img/sprite-icon.svg#republican-star"></use>
</svg>
</div>
<div class="avatar__wrap-name">
<div class="avatar__name">Adam Smith</div>
<div class="chat chat-i">Aenean commodo ligula eget dolor. Aenean massa. Lorem</div>
</div>
</div>
</li>
<li class="people-chat__item">
<div class="avatar avatar--list">
<div class="avatar__wrap-img">
<img class="avatar__img lazy"
src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAEALAAAAAABAAEAAAICTAEAOw=="
data-src="img/hanna.png" alt="">
<svg class="icon republican-elefant">
<use xlink:href="img/sprite-icon.svg#republican-star"></use>
</svg>
</div>
<div class="avatar__wrap-name">
<div class="avatar__name">Hanna Smith</div>
<div class="chat chat-i">Lorem ipsum Lorem ipsum hello america</div>
</div>
</div>
</li>
</ul>
<form class="forma-chat">
<input class="forma-chat__input" type="text" placeholder="text">
<a href="#" class="button button__forma">Share</a>
</form>
</div>
</div>
</div>
</div>
Инициализация slick sliderа :
$(document).ready(function () {
$('.modal__slider-main').slick({
prevArrow: '<button class="slick-prev">back</button>',
nextArrow: '<button class="slick-next">next</button>',
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
appendArrows: $('.controls-arrows--modal'),
asNavFor: '.modal__slider-nav',
});
var slick = $('.modal__slider-nav').slick({
slidesToShow: 3,
slidesToScroll: 1,
asNavFor: '.modal__slider-main',
arrows: false,
dots: true,
appendDots: $('.controls-dots--modal'),
focusOnSelect: true
});
$('.modal__slider-nav .slick-slide').removeClass('slick-active');
$('.modal__slider-nav .slick-slide').eq(0).addClass('slick-active');
$('.modal__slider-main').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
var mySlideNumber = nextSlide;
$('.modal__slider-nav .slick-slide').removeClass('slick-active');
$('.modal__slider-nav .slick-slide').eq(mySlideNumber).addClass('slick-active');
});
});