Owl carousel throwing error with jquery 3.0, here's my code.
function mobile() {
var width = $(window).width();
if (width > 767) {
$('.owl-carousel-br').trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
$('.carousel-lancamentos, .owl-carousel-regioes').trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
} else if (width < 768) {
$('.owl-carousel-br').owlCarousel({
items: 1,
nav: false
});
$('.carousel-lancamentos, .owl-carousel-regioes').owlCarousel({
nav: true,
items: 2,
dots: false,
responsiveClass: true,
navText: [' Anterior', 'Pr贸ximo '],
responsive: {
0: {
items: 2,
nav: true
},
480: {
items: 2,
nav: true
},
768: {
items: 2,
nav: true
}
}
});
}
}
jQuery.Deferred exception: item.find(...).andSelf is not a function TypeError: item.find(...).andSelf is not a function
Will be fixed soon.
+1 bump
Fixed by change "andSelf" to "addBack" inside Owlcarousel code.
works for me
jQuery.Deferred exception: t.find(...).andSelf is not a function TypeError: t.find(...).andSelf is not a function
at r.<anonymous> (http://localhost:3000/assets/js/vendor.js:4:7024)
at HTMLDivElement.r (http://localhost:3000/assets/js/vendor.js:1:15712)
at Function.each (http://localhost:3000/assets/js/vendor.js:1:14866)
at fe.each (http://localhost:3000/assets/js/vendor.js:1:13034)
at r.replace (http://localhost:3000/assets/js/vendor.js:4:6893)
at r.initialize (http://localhost:3000/assets/js/vendor.js:3:28639)
at new r (http://localhost:3000/assets/js/vendor.js:3:24064)
at HTMLDivElement.<anonymous> (http://localhost:3000/assets/js/vendor.js:4:12050)
at Function.each (http://localhost:3000/assets/js/vendor.js:1:14866)
at fe.each (http://localhost:3000/assets/js/vendor.js:1:13034) undefined
vendor.js:4 Uncaught TypeError: t.find(...).andSelf is not a function
@CracyCrazz Do you know when will be fixed?
It's better to go with @romuloinnocencio solution
It would probably be better to add the following to your own javascript, rather than monkeypatching.
$.fn.andSelf = function() {
return this.addBack.apply(this, arguments);
}
This was fixed in 2.2.0.
I think I did something wrong then, because I didn't need that before, when I was on 2.1.6, then today when I upgraded I needed it.
Refer @romuloinnocencio and works with charm.
andSelf is deprecated in jquery 1.8 and replaced with andBack in jquery 3.1.x so if you are usinx 3.1.x go with @romuloinnocencio 's solution
@Asday ,thanks very much ,i meet this problom when using jquery-ui-slider.js . i add
$.fn.andSelf = function() {
return this.addBack.apply(this, arguments);
}
,it works well.
Hey guys,
One year later - changing "andSelf" to "addBack" worked for me too, thank you @romuloinnocencio .
Generally, I do not think that touching the source code is a good idea, but I see no other way out of this.
My setup:
Owl Carousel v 2.0.0
Jquery v3.2.1
The newest version of Owl Carousel (2.2 something) is also unstable with this version of jquery. However, Owl carousel works perfectly fine with jquery 1.12.4 or jquery 2.1.4.
Hope you find this info useful, have a nice day :)
Hey guys,
changing "andSelf" to "addBack" worked for me too, thank you @romuloinnocencio
@Asday Thank you so much .
Thanks @romuloinnocencio
Worked for me....
But solution of @Asday didn't work
Most helpful comment
Fixed by change "andSelf" to "addBack" inside Owlcarousel code.
works for me
http://prntscr.com/c4ip5b