Permalink
Browse files

Forgot to add the type check to see if it was already added

1 parent 66c06df commit bf0d5a61c057a27f20ec71e86f98e965a98b8d2d @mdibbets mdibbets committed Aug 26, 2016
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/js/unslider.js
View
@@ -629,7 +629,10 @@
$.fn.unslider = function(opts) {
return this.each(function(index,elem) {
var $this = $(elem);
-
+ var unslider = $(elem).data('unslider');
+ if(unslider instanceof $.Unslider) {
+ return;
+ }
// Allow usage of .unslider('function_name')
// as well as using .data('unslider') to access the
// main Unslider object

1 comment on commit bf0d5a6

@damien-dd
damien-dd commented on bf0d5a6 Sep 20, 2016 edited

This breaks the following feature described in the doc.:

If a slide gets added or removed, you should call this otherwise things'll probably break.

var slider = $('.my-slider').unslider();

// I don't like this last slide, let's get rid of it
slider.find('li:last').remove();

// Let's recalculate Unslider so it knows what's going on
slider.unslider('calculateSlides');
Please sign in to comment.