Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
owl Carousel is not working after ajax success in python Django

I want to get the parent category list on the slider by clicking the main category's slider list. the second category's sider is not working when I click the main category.

$('.maincategory').owlCarousel({ });

  $(".box").on("click", function(){
     var value= this.id.toString();
     var csr =$("input[name=csrfmiddlewaretoken]").val();
     debugger
     $.ajax({
                 url: 'getParentCategory',
                 type: 'POST',
                 data: {
                 id: value,
                 csrfmiddlewaretoken: csr 
                    },
                 success: function (response) {
                    data = response.results
                    AppendData(data);
                 }
           });
     
   });
   
   function AppendData(data){
     $(".secondCategory").empty();
     debugger;
     var htmls = '';
     if(data.length != 0){
        for (var i = 0; i < data.length; i++) {
           htmls += '<div class="item eight-card-single text-center">'
              htmls += '<a id="{{value.id}}" class="second-category category">'
              htmls +='<img src="/media/uploads/products/logo.jpg">'  
              htmls +='<h5 id="'+ data[i].name +'" class="card-title">'+ data[i].name +'</h5>'
              htmls +='</a>'
              htmls +='</div>'
     }
     $(".secondCategory").append(htmls);
        $('.secondCategory').owlCarousel({            
        });
     } else {
        $(".secondCategory").append("No data");
        
     }
     };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The .empty() method clears element content but doesn't destroy the existing Owl carousel instance on that element, you need to this with $(".secondCategory").trigger("destroy.owl.carousel") before setting the new html content and creating a new Owl carousel instance.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!