0

I am using a slider which is loaded regular $(document).ready(function () {} but on some Pages I have to reload the script with $(document).ajaxComplete(function() {} too.. Means both has to be called.

The Problem is that ajaxComplete is loading anytime I press any Button with Javascript Action.

I am calling the Javascript twice with

$(document).ready(function() {
$('.owl-carousel').owlCarousel({
        items:5,
        lazyLoad:true,
        loop:true,
        margin:10,
        responsiveClass:true,
        dots: false,
}

and with

$(document).ajaxComplete(function() {
  $('.owl-carousel').owlCarousel({
        items:5,
        lazyLoad:true,
        loop:true,
        margin:10,
        responsiveClass:true,
        dots: false,
}

on the same Content because I have to load the ajaxComplete if I change a value.

Can I call ajaxComplete if a Class exist or what is a better way?

There is a <select> with dynamic values on special pages, after user change the value of select than I have to rebuild it.

karadayi
  • 2,212
  • 2
  • 21
  • 36
  • when exactly do you have to rebuild the carousel after the ajax call? Whenever the user clicks anywhere or is there a link to click on or something similar? – Jonas Grumann Jun 02 '16 at 15:50
  • There is a – karadayi Jun 02 '16 at 15:52

1 Answers1

0

Continuing from the comments above. Then just rebuild the carousel when the user changes the select:

$('select').on('change', function() {
    $('.owl-carousel').owlCarousel({
        items:5,
        lazyLoad:true,
        loop:true,
        margin:10,
        responsiveClass:true,
        dots: false,
    });
});
Jonas Grumann
  • 10,438
  • 2
  • 22
  • 40
  • Well by this way the carousel will be loaded after – karadayi Jun 02 '16 at 21:07
  • Here is a similar problem: http://stackoverflow.com/questions/5610321/execute-document-ready-after-ajax-post – karadayi Jun 02 '16 at 21:53