I had a very similar use case. What I did was create a template for the slide, a template for the slider, and then initialized slick in my base page. In the Slider template's constructor, I use a factoryImpl
function to add the individual slides in
Slide template
<dom-module id="slide">
<template>
<div>
<!-- slide content goes here -->
</div>
</template>
<script>
Slide = Polymer({
is: 'slide',
factoryImpl: function(slide) {
//Assume slide is a JS object that I use to set any {{properties}} I'll need
this.property = slide.analagousProperty;
this.otherProperty = someFunction(slide.analagousProperty);
},
properties: {
//Properties defined here
}
});
</script>
</dom-module>
Slider template
<dom-module id="slider">
<template>
<div id="slider">
</div>
<div class="controlHolder">
</div>
</template>
<script>
Slider = Polymer({
is: 'slider',
factoryImpl: function(slides) {
var destination = Polymer.dom(this.$.slider);
for (i = 0; i < slides.length; i++) {
var slide = new Slide(slides[i]).querySelector('div');
destination.appendChild(slide);
}
Polymer.dom.flush();
},
ready: function() {
$('#slider').on('afterChange',
function(event, slick, currentSlide) {
$('.slick-center .play-button').click(function() {
});
});
}
});
</script>
</dom-module>
Actual page
<head>
<script src="../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="../bower_components/slick-carousel/slick/slick.min.js"></script>
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../base_slide.html">
<link rel="import" href="../base_slider.html">
<link rel="stylesheet" type="text/css" href="../bower_components/slick-carousel/slick/slick.css" />
<link rel="stylesheet" type="text/css" href="../bower_components/slick-carousel/slick/slick-theme.css" />
<link rel="stylesheet" type="text/css" href="../myCustomStyleSheet.css">
</head>
<body>
<div class="mainContent">
<h1>Some heading</h1>
</div>
<div id="slideContent">
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var slides = [
{
sourceImage: '1.jpg',
caption: 'A kindly person'
},
{
sourceImage: '2.jpg',
caption: 'A kindly person'
},
{
sourceImage: '3.jpg',
caption: 'A kindly person'
},
{
sourceImage: '4.jpg',
caption: 'A kindly person'
},
{
sourceImage: '5.jpg',
caption: 'A kindly person'
},
{
sourceImage: '6.jpg',
caption: 'A kindly person'
},
{
sourceImage: '7.jpg',
caption: 'A kindly person'
}
];
var slider = new Slider(slides);
document.getElementById('slideContent').appendChild(slider);
$('#slider').slick({
arrows: true,
initialSlide: 4,
dots: true,
infinite: true,
cssEase: 'ease',
accessibility: true,
swipeToSlide: true,
focusOnSelect: true,
centerMode: true, //Requires odd number of slides to show
slidesToShow: 5,
centerPadding: '60px',
adaptiveHeight: true
});
});
</script>
</body>
This is by no means my final implementation, but it shows another way to get the job done: use the querySelector() method to rip out the div you want from your custom item, then use appendChild() in the slider's constructor to drop in the stuff you want.