I am using cycle2, a jquery plugin that turns a bunch of divs containing images or video into a rotating slideshow with transitions. The initial load of the stache template loads fine, from a list of slides (can.List). But after the plugin loads it alters the dom and I guess confuses the stache updater so it can’t find the list anymore and does not update. When I remove the plugin, it updates as expected.
sign.stache
<div id="slideshows">
{{#each ./slideshows}}
<div {$id}="id" {$class}="classes" {$style}="parseCSS('slideshow', cssrule)" data-cycle-slides="> div" >
{{#each slides}}
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition">
{{#eq type 'video'}}
<video id="video-{{id}}" {$src}="localUrl(id, url, 'media/s')" type="video/mp4" />
{{else}}
<img id="img-{{id}}" {$src}="localUrl(id, url, 'media/s')" />
{{/eq}}
</div>
{{/each}}
</div>
{{/each}}
</div>
rendered HTML without the plugin:
<div id="slideshows">
<div {$id}="id" {$class}="classes" {$style}="parseCSS('slideshow', cssrule)" data-cycle-slides="> div" id="Slide" class="" style="position: absolute; top: 0px; left: 0px; width: 1920px; height: 1080px;">
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" id="56e5d8ced86784e8638b4567" data-cycle-timeout="5000" data-cycle-fx="fade">
<img {$src}="localUrl(id, url, 'media/s')" id="img-56e5d8ced86784e8638b4567" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Sky_1280.jpg">
</div>
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" id="56e5d801d867844f628b4567" data-cycle-timeout="10026.667" data-cycle-fx="fade">
<video {$src}="localUrl(id, url, 'media/s')" type="video/mp4" id="video-56e5d801d867844f628b4567" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Test1.mp4"></video>
</div>
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" id="56e5d818d867845f628b4567" data-cycle-timeout="10048" data-cycle-fx="fade">
<video {$src}="localUrl(id, url, 'media/s')" type="video/mp4" id="video-56e5d818d867845f628b4567" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Test2.mp4"></video>
</div>
</div>
</div>
with plugin:
<div id="slideshows">
<div {$id}="id" {$class}="classes" {$style}="parseCSS('slideshow', cssrule)" data-cycle-slides="> div" id="Slide" class="cycle-slideshow" style="position: absolute; top: 0px; left: 0px; width: 1920px; height: 1080px;">
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" data-cycle-timeout="5000" data-cycle-fx="fade" style="position: static; top: 0px; left: 0px; z-index: 100; opacity: 1; display: block; visibility: hidden;" class="cycle-slide cycle-sentinel">
<img {$src}="localUrl(id, url, 'media/s')" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Sky_1280.jpg" style="visibility: hidden;">
</div>
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" id="56e5d8ced86784e8638b4567" data-cycle-timeout="5000" data-cycle-fx="fade" style="position: absolute; top: 0px; left: 0px; z-index: 100; opacity: 0; display: block; visibility: hidden;" class="cycle-slide">
<img {$src}="localUrl(id, url, 'media/s')" id="img-56e5d8ced86784e8638b4567" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Sky_1280.jpg">
</div>
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" id="56e5d801d867844f628b4567" data-cycle-timeout="10026.667" data-cycle-fx="fade" style="position: absolute; top: 0px; left: 0px; z-index: 99; visibility: visible; opacity: 1; display: block;" class="cycle-slide cycle-slide-active">
<video {$src}="localUrl(id, url, 'media/s')" type="video/mp4" id="video-56e5d801d867844f628b4567" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Test1.mp4"></video>
</div>
<div {$id}="id" {$data-cycle-timeout}="duration(props.duration)" {$data-cycle-fx}="props.transition" id="56e5d818d867845f628b4567" data-cycle-timeout="10048" data-cycle-fx="fade" style="position: absolute; top: 0px; left: 0px; z-index: 97; visibility: hidden;" class="cycle-slide">
<video {$src}="localUrl(id, url, 'media/s')" type="video/mp4" id="video-56e5d818d867845f628b4567" src="http://dev.menuboardmanager.com/wp-content/plugins/menuboard-manager/app/public/mediaStorage/dovid/gallery/Test2.mp4"></video>
</div>
</div>
</div>
notice the addition of the additional hidden div with the cycle-sentinel class.
Is there anyway around this? Or will I need to scrap the plugin? If so, how can I create the slideshow effect using stache directives and functions? I could do something like <img {$id}="currentSlide.id" {$src}="currentSlide.url" />
with timeouts in the viewmodel to update currentSlide, but then I would lose the transition effects.