Owlcarousel2: The event 'next.owl.carousel' does not work

Created on 22 Apr 2016  路  6Comments  路  Source: OwlCarousel2/OwlCarousel2

Good afternoon.

I have several carousels on my site for advertising. Within each two possibilities I have in the div 'item': A '<img>' or '<a target="blank"> <img> </a>'. The problem is that when I go to link the carousel remains slow.

To fix this, try to use the event 'next.owl.carousel' after you click on the link. But it does not work the event. I use the example in docs information.

This is my code of javascript for the carousel:

$(document).ready(function() {

  $("#owl-publicidad-h-grande").owlCarousel({
      autoPlay: 6000, //Set AutoPlay to 6 seconds
      navigation : false, // Show next and prev buttons
      slideSpeed : 10000,
      paginationSpeed : 400,
      singleItem:true
  });

    // Fix the pause in carousel.
    var owlh = $('#owl-publicidad-h-grande');
    // Go to the next item
    $('#owl-publicidad-h-grande .item a').click(function() {
        owlh.trigger('next.owl.carousel');
    });

});

Thank you very much

Most helpful comment

There's an error in the docs. The following will work:

$('#owl-publicidad-h-grande .item a').click(function() {
     owlh.trigger('owl.next');
});

// Or to go to a previous slide
$('#owl-publicidad-h-grande .item a').click(function() {
     owlh.trigger('owl.prev');
});

All 6 comments

to fix the pause in carousel try this syntax instead....
.on('#owl-publicidad-h-grande .item a', function (e) {
owlh.trigger('next.owl.carousel');
});

There's an error in the docs. The following will work:

$('#owl-publicidad-h-grande .item a').click(function() {
     owlh.trigger('owl.next');
});

// Or to go to a previous slide
$('#owl-publicidad-h-grande .item a').click(function() {
     owlh.trigger('owl.prev');
});

Thanks, it's working for me.

I can't believe it's 2020 and this is still the case (mistake in documentation), many thanks @samvantoever !

hi, I have the same issue. I checked both of these triggers. it works on html. but when I move it to WordPress.(uses its own jQuery I think). its not working anymore. what do you prefer for that guys ?

sorry guys that I founded next and prev triggers are only available only when the items count is grater than options items in your js script.
in my case I have only 2 posts and I've set items : 4 so the trigger for next and prev is not actually works. also I have sets loop: true

Was this page helpful?
0 / 5 - 0 ratings