logo
down
shadow

Bootstrap multiple carousel not working on thumbnails click


Bootstrap multiple carousel not working on thumbnails click

Content Index :

To fix this issue ID's have to be unique. Give each carousel and each thumbcarousel an ID of its own and you're good to go. Use classes for styling them.
.product-slider {
  padding: 45px;
}

.product-slider .carousel {
  border: 4px solid #1089c0;
  margin: 0;
}

.product-slider .thumbcarousel {
  margin: 12px 0 0;
  padding: 0 45px;
}

.product-slider .thumbcarousel .item {
  text-align: center;
}

.product-slider .thumbcarousel .item .thumb {
  border: 4px solid #cecece;
  width: 20%;
  margin: 0 2%;
  display: inline-block;
  vertical-align: middle;
  cursor: pointer;
  max-width: 98px;
}

.product-slider .thumbcarousel .item .thumb:hover {
  border-color: #1089c0;
}

.product-slider .item img {
  width: 100%;
  height: auto;
}

.carousel-control {
  color: #0284b8;
  text-align: center;
  text-shadow: none;
  font-size: 30px;
  width: 30px;
  height: 30px;
  line-height: 20px;
  top: 23%;
}

.carousel-control:hover,
.carousel-control:focus,
.carousel-control:active {
  color: #333;
}

.carousel-caption,
.carousel-control .fa {
  font: normal normal normal 30px/26px FontAwesome;
}

.carousel-control {
  background-color: rgba(0, 0, 0, 0);
  bottom: auto;
  font-size: 20px;
  left: 0;
  position: absolute;
  top: 30%;
  width: auto;
}

.carousel-control.right,
.carousel-control.left {
  background-color: rgba(0, 0, 0, 0);
  background-image: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">



<div class="container">
  <div class="row">
    <div class="col-md-12">
      <button class="btn btn-primary" data-toggle="modal" data-target="#myModal1">Modal 1</button>
      <button class="btn btn-primary" data-toggle="modal" data-target="#myModal2">Modal 2</button>
      <button class="btn btn-primary" data-toggle="modal" data-target="#myModal3">Modal 3</button>
    </div>
  </div>
</div>


<div id="myModal1" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <div class="product-slider">
          <div id="carousel_1" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
              <div class="item active"> <img src="https://picsum.photos/950/500?image=1"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=2"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=3"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=4"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=5"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=6"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=7"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=8"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=9"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=10"> </div>
            </div>
          </div>
          <div class="clearfix">
            <div id="thumbcarousel_1" class="carousel thumbcarousel slide" data-interval="false">
              <div class="carousel-inner">
                <div class="item active">
                  <div data-target="#carousel_1" data-slide-to="0" class="thumb"><img src="https://picsum.photos/60/60?image=1"></div>
                  <div data-target="#carousel_1" data-slide-to="1" class="thumb"><img src="https://picsum.photos/60/60?image=2"></div>
                  <div data-target="#carousel_1" data-slide-to="2" class="thumb"><img src="https://picsum.photos/60/60?image=3"></div>
                  <div data-target="#carousel_1" data-slide-to="3" class="thumb"><img src="https://picsum.photos/60/60?image=4"></div>
                  <div data-target="#carousel_1" data-slide-to="4" class="thumb"><img src="https://picsum.photos/60/60?image=5"></div>
                </div>
                <div class="item">
                  <div data-target="#carousel_1" data-slide-to="5" class="thumb"><img src="https://picsum.photos/60/60?image=6"></div>
                  <div data-target="#carousel_1" data-slide-to="6" class="thumb"><img src="https://picsum.photos/60/60?image=7"></div>
                  <div data-target="#carousel_1" data-slide-to="7" class="thumb"><img src="https://picsum.photos/60/60?image=8"></div>
                  <div data-target="#carousel_1" data-slide-to="8" class="thumb"><img src="https://picsum.photos/60/60?image=9"></div>
                  <div data-target="#carousel_1" data-slide-to="9" class="thumb"><img src="https://picsum.photos/60/60?image=10"></div>
                </div>
              </div>
              <!-- /carousel-inner -->
              <a class="left carousel-control" href="#thumbcarousel_1" role="button" data-slide="prev"> <i class="fa fa-angle-left" aria-hidden="true"></i> </a>
              <a class="right carousel-control" href="#thumbcarousel_1" role="button" data-slide="next"><i class="fa fa-angle-right" aria-hidden="true"></i> </a> </div>
            <!-- /thumbcarousel -->

          </div>
        </div>
      </div>
    </div>
  </div>
</div>


<div id="myModal2" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <div class="product-slider">
          <div id="carousel_2" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
              <div class="item active"> <img src="https://picsum.photos/950/500?image=11"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=12"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=13"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=14"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=15"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=16"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=17"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=18"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=19"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=20"> </div>
            </div>
          </div>
          <div class="clearfix">
            <div id="thumbcarousel_2" class="carousel thumbcarousel slide" data-interval="false">
              <div class="carousel-inner">
                <div class="item active">
                  <div data-target="#carousel_2" data-slide-to="0" class="thumb"><img src="https://picsum.photos/60/60?image=11"></div>
                  <div data-target="#carousel_2" data-slide-to="1" class="thumb"><img src="https://picsum.photos/60/60?image=12"></div>
                  <div data-target="#carousel_2" data-slide-to="2" class="thumb"><img src="https://picsum.photos/60/60?image=13"></div>
                  <div data-target="#carousel_2" data-slide-to="3" class="thumb"><img src="https://picsum.photos/60/60?image=14"></div>
                  <div data-target="#carousel_2" data-slide-to="4" class="thumb"><img src="https://picsum.photos/60/60?image=15"></div>
                </div>
                <div class="item">
                  <div data-target="#carousel_2" data-slide-to="5" class="thumb"><img src="https://picsum.photos/60/60?image=16"></div>
                  <div data-target="#carousel_2" data-slide-to="6" class="thumb"><img src="https://picsum.photos/60/60?image=17"></div>
                  <div data-target="#carousel_2" data-slide-to="7" class="thumb"><img src="https://picsum.photos/60/60?image=18"></div>
                  <div data-target="#carousel_2" data-slide-to="8" class="thumb"><img src="https://picsum.photos/60/60?image=19"></div>
                  <div data-target="#carousel_2" data-slide-to="9" class="thumb"><img src="https://picsum.photos/60/60?image=20"></div>
                </div>
              </div>
              <!-- /carousel-inner -->
              <a class="left carousel-control" href="#thumbcarousel_2" role="button" data-slide="prev">
                <i class="fa fa-angle-left" aria-hidden="true"></i> </a>
              <a class="right carousel-control" href="#thumbcarousel_2" role="button" data-slide="next"><i
                                    class="fa fa-angle-right" aria-hidden="true"></i> </a>
            </div>
            <!-- /thumbcarousel -->

          </div>
        </div>
      </div>
    </div>
  </div>
</div>


<div id="myModal3" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <div class="product-slider">
          <div id="carousel_3" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
              <div class="item active"> <img src="https://picsum.photos/950/500?image=21"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=22"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=23"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=24"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=25"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=26"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=27"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=28"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=29"> </div>
              <div class="item"> <img src="https://picsum.photos/950/500?image=30"> </div>
            </div>
          </div>
          <div class="clearfix">
            <div id="thumbcarousel_3" class="carousel thumbcarousel slide" data-interval="false">
              <div class="carousel-inner">
                <div class="item active">
                  <div data-target="#carousel_3" data-slide-to="0" class="thumb"><img src="https://picsum.photos/60/60?image=21"></div>
                  <div data-target="#carousel_3" data-slide-to="1" class="thumb"><img src="https://picsum.photos/60/60?image=22"></div>
                  <div data-target="#carousel_3" data-slide-to="2" class="thumb"><img src="https://picsum.photos/60/60?image=23"></div>
                  <div data-target="#carousel_3" data-slide-to="3" class="thumb"><img src="https://picsum.photos/60/60?image=24"></div>
                  <div data-target="#carousel_3" data-slide-to="4" class="thumb"><img src="https://picsum.photos/60/60?image=25"></div>
                </div>
                <div class="item">
                  <div data-target="#carousel_3" data-slide-to="5" class="thumb"><img src="https://picsum.photos/60/60?image=26"></div>
                  <div data-target="#carousel_3" data-slide-to="6" class="thumb"><img src="https://picsum.photos/60/60?image=27"></div>
                  <div data-target="#carousel_3" data-slide-to="7" class="thumb"><img src="https://picsum.photos/60/60?image=28"></div>
                  <div data-target="#carousel_3" data-slide-to="8" class="thumb"><img src="https://picsum.photos/60/60?image=29"></div>
                  <div data-target="#carousel_3" data-slide-to="9" class="thumb"><img src="https://picsum.photos/60/60?image=30"></div>
                </div>
              </div>
              <!-- /carousel-inner -->
              <a class="left carousel-control" href="#thumbcarousel_3" role="button" data-slide="prev">
                <i class="fa fa-angle-left" aria-hidden="true"></i> </a>
              <a class="right carousel-control" href="#thumbcarousel_3" role="button" data-slide="next"><i
                                    class="fa fa-angle-right" aria-hidden="true"></i> </a>
            </div>
            <!-- /thumbcarousel -->

          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Tag : php , By : jch
Date : March 29 2020, 07:55 AM
hope this fix your issue Find the common denominator between all the images. In other words, this code snippet:
<li class="span2">
  <div class="thumbnail">
    <img src="IMAGE_URL" alt="">
  </div>
</li>
<div class="carousel-inner">
  <div class="item active">
        <ul class="thumbnails">
          <?php foreach($image_url as $image) { ?>
             <li class="span2">
               <div class="thumbnail">
                 <img src="<?php echo $image; ?>" alt="">
               </div>
             </li>
          <?php } ?>          
        </ul>
  </div>

Tag : html , By : Brian
Date : March 29 2020, 07:55 AM
should help you out I've made a fork from the example I gave you.
HTML:
<div class="container">
        <div id="main_area">
                <!-- Slider -->
                <div class="row">
                    <div class="col-xs-12" id="slider">
                        <!-- Top part of the slider -->
                        <div class="row">
                            <div class="col-sm-8" id="carousel-bounding-box">
                                <div class="carousel slide" id="myCarousel">
                                    <!-- Carousel items -->
                                    <div class="carousel-inner">
                                        <div class="active item" data-slide-number="0">
                                        <img src="http://placehold.it/770x300&amp;text=one"></div>

                                        <div class="item" data-slide-number="1">
                                        <img src="http://placehold.it/770x300&amp;text=two"></div>

                                        <div class="item" data-slide-number="2">
                                        <img src="http://placehold.it/770x300&amp;text=three"></div>

                                        <div class="item" data-slide-number="3">
                                        <img src="http://placehold.it/770x300&amp;text=four"></div>

                                        <div class="item" data-slide-number="4">
                                        <img src="http://placehold.it/770x300&amp;text=five"></div>

                                        <div class="item" data-slide-number="5">
                                        <img src="http://placehold.it/770x300&amp;text=six"></div>
                                    </div><!-- Carousel nav -->
                                    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                                        <span class="glyphicon glyphicon-chevron-left"></span>                                       
                                    </a>
                                    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                                        <span class="glyphicon glyphicon-chevron-right"></span>                                       
                                    </a>                                
                                    </div>
                            </div>

                            <div class="col-sm-4" id="carousel-text"></div>

                            <div id="slide-content" style="display: none;">
                                <div id="slide-content-0">
                                    <h2>Slider One</h2>
                                    <p>Lorem Ipsum Dolor</p>
                                    <p class="sub-text">October 24 2012 - <a href="#">Read more</a></p>
                                </div>

                                <div id="slide-content-1">
                                    <h2>Slider Two</h2>
                                    <p>Lorem Ipsum Dolor</p>
                                    <p class="sub-text">October 24 2012 - <a href="#">Read more</a></p>
                                </div>

                                <div id="slide-content-2">
                                    <h2>Slider Three</h2>
                                    <p>Lorem Ipsum Dolor</p>
                                    <p class="sub-text">October 24 2012 - <a href="#">Read more</a></p>
                                </div>

                                <div id="slide-content-3">
                                    <h2>Slider Four</h2>
                                    <p>Lorem Ipsum Dolor</p>
                                    <p class="sub-text">October 24 2012 - <a href="#">Read more</a></p>
                                </div>

                                <div id="slide-content-4">
                                    <h2>Slider Five</h2>
                                    <p>Lorem Ipsum Dolor</p>
                                    <p class="sub-text">October 24 2012 - <a href="#">Read more</a></p>
                                </div>

                                <div id="slide-content-5">
                                    <h2>Slider Six</h2>
                                    <p>Lorem Ipsum Dolor</p>
                                    <p class="sub-text">October 24 2012 - <a href="#">Read more</a></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!--/Slider-->

                <div class="row hidden-xs" id="slider-thumbs">
                        <!-- Bottom switcher of slider -->
                        <ul class="hide-bullets">
                            <li class="col-sm-2">
                                <a class="thumbnail" id="carousel-selector-0"><img src="http://placehold.it/170x100&amp;text=one"></a>
                            </li>

                            <li class="col-sm-2">
                                <a class="thumbnail" id="carousel-selector-1"><img src="http://placehold.it/170x100&amp;text=two"></a>
                            </li>

                            <li class="col-sm-2">
                                <a class="thumbnail" id="carousel-selector-2"><img src="http://placehold.it/170x100&amp;text=three"></a>
                            </li>

                            <li class="col-sm-2">
                                <a class="thumbnail" id="carousel-selector-3"><img src="http://placehold.it/170x100&amp;text=four"></a>
                            </li>

                            <li class="col-sm-2">
                                <a class="thumbnail" id="carousel-selector-4"><img src="http://placehold.it/170x100&amp;text=five"></a>
                            </li>

                            <li class="col-sm-2">
                                <a class="thumbnail" id="carousel-selector-5"><img src="http://placehold.it/170x100&amp;text=six"></a>
                            </li>
                        </ul>                 
                </div>
        </div>
</div>
.hide-bullets {
list-style:none;
margin-left: -40px;
margin-top:20px;
}
  jQuery(document).ready(function($) {

        $('#myCarousel').carousel({
                interval: 5000
        });

        $('#carousel-text').html($('#slide-content-0').html());

        //Handles the carousel thumbnails
        $('[id^=carousel-selector-]').click( function(){
                var id_selector = $(this).attr("id");
                var id = id_selector.substr(id_selector.length -1);
                var id = parseInt(id);
                $('#myCarousel').carousel(id);
        });


        // When the carousel slides, auto update the text
        $('#myCarousel').on('slid.bs.carousel', function (e) {
                 var id = $('.item.active').data('slide-number');
                $('#carousel-text').html($('#slide-content-'+id).html());
        });
});

Tag : javascript , By : Brian
Date : March 29 2020, 07:55 AM
like below fixes the issue This method requires your carousels to have ID = myCarousel1, myCarousel2 etc.
and your selectors for the corresponding carousel to be carousel-selector1-1, carousel-selector1-2 ... and carousel-selector2-1, carousel-selector2-2
$('.customCarousel').carousel({
     interval: 4000
 });

 // handles the carousel thumbnails
 $('[id^=carousel-selector]').click(function () {
     var id_selector = $(this).attr("id");
     var id = id_selector.substr(id_selector.length - 1);
     id = parseInt(id);
     var parent = $(this).closest('ul').data('carousel');
     $('#myCarousel' + parent).carousel(id);
     $('[id^=carousel-selector' + parent +'-]').removeClass('selected');
     $(this).addClass('selected');
 });

 // when the carousel slides, auto update
 $('.customCarousel').on('slid', function (e) {
     var cont = $(this).data('carousel');
     var id = $('#myCarousel'+ cont +' .item.active').data('slide-number');
     id = parseInt(id);
     $('[id^=carousel-selector' +cont+'-]').removeClass('selected');
     $('[id^=carousel-selector'+cont+'-' + id + ']').addClass('selected');
 });

Tag : jquery , By : scotta01
Date : March 29 2020, 07:55 AM
it fixes the issue Reason why you getting that "Uncaught ReferencError" is because the Jquery wasn't loaded or finish loading by the time your code was executed.
This was the code where it is throwing the error:
$('#carouselHacked').carousel({
  interval: false
});
$(function() {
    $('#carouselHacked').carousel({
      interval: false
    });

    // let's put this code also so it won't throw an error when it runs
    $('.thumbnails-carousel').thumbnailsCarousel();
});

Tag : javascript , By : Mariamario
Date : March 29 2020, 07:55 AM
Hope this helps I created a Page and Add Belowe Liberaries:
jquery-1.10.2.js bootstrap.min.js bootstrap.min.css
Related Posts Related QUESTIONS :
  • how to make search and form category merges like amazon on bootstrap
  • Bootstrap: Rearranging rows into columns and changing the order of elements
  • How can I move a label under a text box?
  • How save LinearGradient To database
  • How to reposition an image with a linear gradient using css?
  • HTML audio will not play when page opened by batch file
  • CSS Three Tone Diagonal Background
  • How to use slots inside of template components in HTML
  • Using span tags in meta description & title, for dual languages
  • How to make an icon/span selectable by pressing Tab key?
  • Add dynamic margins using UI Kit
  • Add margin-top to textbox
  • What is the correct semantic HTML markup for a title (book, movie, etc.), according to the spec? Is it an <em> tag
  • How to make an animation in Geoserver or in Leaflet
  • Buttons overlapping when shrinking window
  • Stretch an element to the end of the automatically calculated grid, not just the explicit grid
  • What relation is there between Angular's <ng-content> and ShadowDOM
  • CSS background for div element is not working
  • CSS Marquee: multiple paragraphs overlaps
  • I want to align search bar to extreme right
  • Getting blank white space to the left of content inside pre tags
  • My viewer.html won't load any css and jss files
  • How to apply multiple styles to HTML to only part of a title?
  • Want to make text div transparent on a parallax area
  • Is there a way to make this ID plus descendants CSS rule less specific?
  • Is there a way to drop in a stylesheet to get a Material theme or similar for all form elements on the page?
  • How do I make a sideways L look in html/css?
  • Why won't the color #e67d22e1 display in Safari?
  • How to select specific tag's attribute value with xPath?
  • How to make div rows fill available height
  • How to fix text inside a block that grows
  • svg hexagon halftone pattern
  • How to edit a website's element's background colors using a chromium extention
  • What is the main tag in HTML5 ? How does it differ from body tag?
  • My image is flowing out from my div column. How I can fix it and made the image full-size into div
  • How to draw line in react
  • Why Transition css is not working in child selector css
  • How to modify materialize css select option?
  • How to center some text in a rectangle in CSS?
  • How do I equally space out css grid columns?
  • How to make sure all the parts of a macro are running correctly?
  • How to adjust the zoom of website at different browser at different screen size?
  • Can't set max height on child div properly
  • Why background color is not applying to DIV container?
  • Need to select the first-child
  • No space between attributes in buttons
  • How can I block google from crawling my page, but still let Baidu do it?
  • Rendering html content in matToolTip (Angular)
  • Embedding an iframe when iframe height is variable
  • How to use 'word-break: break-word' with link inside of text?
  • How I can animate circular progress bar from left to right?
  • Angular 6 - How can I hide a div onclick of outside of that div
  • How to fill an inline-block div with a solid color?
  • Form file doesn't align with rest of form
  • How to trim off left and right sides of image evenly as I reduce my screen size? (@media query)
  • How can I password protect a section of a static website?
  • Move a div up when I hover over it
  • Why is "align" not a valid attribute of div but still works?
  • Behavior with height/minHeight and display:flex
  • How can i change my h2 title to <p> text while keeping size and alignment?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com