Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Cannot read property 'offsetWidth' of undefined with bootstrap carousel script

I created a carousel with Bootstrap 3.3 and it works on my local machine, but when I upload the whole thing on server where the bootstrap js file is being compiled together with other files in a single file, I get this error:

Cannot read property 'offsetWidth' of undefined - has anybody faced this and are there any known solutions to this issue?

like image 230
Xeen Avatar asked Mar 13 '15 08:03

Xeen


3 Answers

For me it was because I hadn't set an active class on any of the slides.

like image 87
Jack James Avatar answered Oct 17 '22 20:10

Jack James


For me, I changed class='carousel-item' to class='item' like this

<div class="item">
    <img class="img-responsive" src="..." alt="...">
</div>
like image 106
sunny Avatar answered Oct 17 '22 20:10

sunny


Remove the class 'Carousal slide' on page load & add it dynamically when image gets loaded using jquery.This fixed for me

like image 8
Anup Shetty Avatar answered Oct 17 '22 20:10

Anup Shetty