swiper 2016년 이전버전 destroy 관련이슈
최근 스와이퍼 버전에도 이런 이슈가 있는지는 모르겠다.
같은 클래스명을 destroy
하면 에러가 난다.
다음처럼 인스턴스를 생성할 때 각기다른 변수에 담고 destroy해야된다.
return {
buildSwiper : function() {
this.swiperObj_0 = new Swiper(this.bestTabSub.eq(0), this.swiperOpts);
this.swiperObj_1 = new Swiper(this.bestTabSub.eq(1), this.swiperOpts);
this.swiperObj_2 = new Swiper(this.bestTabSub.eq(2), this.swiperOpts);
this.swiperObj_3 = new Swiper(this.bestTabSub.eq(3), this.swiperOpts);
this.swiperObj_4 = new Swiper(this.bestTabSub.eq(4), this.swiperOpts);
},
categoryTabFunc : function(e) {
e.preventDefault();
var target = $(e.currentTarget),
targetParent = target.parent(),
targetParentIndex = targetParent.index();
this.tabCategoryItem.removeClass(defParams.selectClass).eq(targetParentIndex).addClass(defParams.selectClass);
this.tabCategoryItem.eq(targetParentIndex).find(this.tabSubItem).removeClass(defParams.activeClass).eq(0).addClass(defParams.activeClass);
switch (true) {
case (targetParentIndex === 0) :
this.swiperObj_0.destroy();
this.swiperObj_0 = new Swiper(this.bestTabSub.eq(0), this.swiperOpts);
break
case (targetParentIndex === 1) :
this.swiperObj_1.destroy();
this.swiperObj_1 = new Swiper(this.bestTabSub.eq(1), this.swiperOpts);
break
case (targetParentIndex === 2) :
this.swiperObj_2.destroy();
this.swiperObj_2 = new Swiper(this.bestTabSub.eq(2), this.swiperOpts);
break
case (targetParentIndex === 3) :
this.swiperObj_3.destroy();
this.swiperObj_3 = new Swiper(this.bestTabSub.eq(3), this.swiperOpts);
break
case (targetParentIndex === 4) :
this.swiperObj_4.destroy();
this.swiperObj_4 = new Swiper(this.bestTabSub.eq(4), this.swiperOpts);
break
default :
break
}
},
}