I am using swipe.js in a project.
I am dynamically changing the data in the slider.
I have been just creating a new swipe object when the data changes, however it is not destroying the callbacks etc, which is causing problems. How can I destroy the swipe object, or at least refresh it?
<div id='flyers'>
<ul>
<li style='display:block'></li>
<li style='display:none'></li>
<li style='display:none'></li>
</ul>
</div>
window.slider = new Swipe(document.getElementById('flyers'), {
startSlide: 0,
speed: 200,
callback: function(event, index, elem) {
$('#home .flyerNav .selected').removeClass('selected');
$('#home .flyerNav').children().eq(index).addClass('selected');
$('#home .flyerLoves').attr('imgId',slides[index].imgId);
daterizer(index);
}
});
Try the swipe2 branch. It has a
killmethod that will remove the event listeners it sets up. I’m assuming it’s not officially “done” yet but it might work for you if it doesn’t have any glaring bugs. You’d callwindow.slider.kill()just before you instantiate the new one.