Jquery Content Carousel not loading items properly

Suhail Mumtaz Awan

I am working on simple bootstrap content carousel.... Live Demo

The problem is that there should load 3 items each slide.....as can be seen from code but there loads only one item on each slide....The rest of the slider is working good except the item loading...

Razor Code :

<div class="container img-responsive" style="background: #d9e5e9;
padding-left: -0px; padding-bottom: 10px; padding-top: 10px;
margin: 20px auto; width: 980px;">
    <div class="carousel slide" id="myCarousel">
        <div class="carousel-inner">
            @{
                int counter = 0;
                foreach (var item in ViewBag.LoadEps)
                {
                    if (counter == 0)
                    {
                        <div class="item active">
                            <div class="col-lg-4">   
   <a href="@Url.Action("LoadEpisodes", "Home", new { id = item.VideoId,
    epId =item.VideoEpisodeId, name = item.Title.Replace(" ", "-")}, null)"
    style="color: white; text-align: center; line-height: 12px;">
    <img src="@Url.Content(item.PosterUrl)" height="130" 
    width="200" alt="@item.Title" class="ImageBorder" /><br />@item.Title
                                    </a>
                            </div>
                        </div>
                    }

                    else
                    {
                        <div class="item">
                            <div class="col-lg-4">
                               
    <a href="@Url.Action("LoadEpisodes", "Home", new { id = item.VideoId,
    epId =item.VideoEpisodeId, name = item.Title.Replace(" ", "-")}, null)"
    style="color: white; text-align: center; line-height: 12px;">
    <img src="@Url.Content(item.PosterUrl)" height="130" 
    width="200" alt="@item.Title" class="ImageBorder" /><br />@item.Title
                                    </a>
                            </div>
                        </div>
                    }
                    counter++;
                }
            }
        </div>
        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
        <i class="glyphicon glyphicon-chevron-left"></i></a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next">
        <i class="glyphicon glyphicon-chevron-right"></i></a>
    </div>
</div>

Style

<style>
    .carousel-inner .active.left {
        left: -25%;
    }

    .carousel-inner .next {
        left: 25%;
    }

    .carousel-inner .prev {
        left: -25%;
    }

    .carousel-control {
        width: 4%;
    }

        .carousel-control.left, .carousel-control.right {
            margin-left: 15px;
            background-color: #036ca6;
        }
</style>

Script

<script>
    $(document).ready(function () {
        $('#myCarousel').carousel({
            interval: 4000
        })

        $('.carousel .item').each(function () {
            var next = $(this).next();
            if (!next.length) {
                next = $(this).siblings(':first');
            }
            next.children(':first-child').clone().appendTo($(this));

            for (var i = 0; i < 2; i++) {
                next = next.next();
                if (!next.length) {
                    next = $(this).siblings(':first');
                }

                next.children(':first-child').clone().appendTo($(this));
            }
        });
    });
</script>

The problem only with the items loading, although slider is working fine, libraries loading fine.... I have no idea how to test it and find error like console errors in firebug... I wasn't able to sort out the jquery by myself.... If some one please any type of help will be appreciated..... Thanks for your time..

odedta

Here is a working example of OWL carousel which works fine anywhere I've tried, if it doesn't work for you, hop on chat and i'll help you get it working.

DEMO

<div id="owl-example" class="owl-carousel">
    <div> <img src="http://cdn.oxwordsblog.wpfuel.co.uk/wpcms/wp-content/uploads/Lion_iStock_XSmall-300x300.jpg?24a0bc" /> </div>
  <div> <img src="http://www.wildlife-pictures-online.com/image-files/lion-male_2724.jpg" /> </div>
  <div> <img src="http://upload.wikimedia.org/wikipedia/commons/9/94/Lion_Foret.jpg" /> </div>
    <div> <img src="http://cdn.oxwordsblog.wpfuel.co.uk/wpcms/wp-content/uploads/Lion_iStock_XSmall-300x300.jpg?24a0bc" /> </div>
  <div> <img src="http://www.wildlife-pictures-online.com/image-files/lion-male_2724.jpg" /> </div>
  <div> <img src="http://upload.wikimedia.org/wikipedia/commons/9/94/Lion_Foret.jpg" /> </div>
    <div> <img src="http://cdn.oxwordsblog.wpfuel.co.uk/wpcms/wp-content/uploads/Lion_iStock_XSmall-300x300.jpg?24a0bc" /> </div>
  <div> <img src="http://www.wildlife-pictures-online.com/image-files/lion-male_2724.jpg" /> </div>
  <div> <img src="http://upload.wikimedia.org/wikipedia/commons/9/94/Lion_Foret.jpg" /> </div>
</div>

$(document).ready(function() {
    $("#owl-example").owlCarousel({
        autoPlay: 3000, //Set AutoPlay to 3 seconds
        items : 3,   
    });
});

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Carousel not working after adding items dynamically with jQuery

分類Dev

Bootstrap carousel content fade

分類Dev

Loading AJAX content inside jQuery tooltip while hovering

分類Dev

JQuery - Display multiple items (6) within viewport with Bootstrap 4's Carousel

分類Dev

Carousel/Slider images not resizing properly

分類Dev

JQuery carousel track looping

分類Dev

Ajax content loading issues

分類Dev

Checkbox not loading properly in Angular 4

分類Dev

Render child items with their own layout in a carousel control

分類Dev

Twitter Bootstrap Carousel display two items

分類Dev

Align items with justify content

分類Dev

Loading Multiple Listbox Items to database

分類Dev

Load dynamic content in Owl Carousel 2

分類Dev

Android WebView not loading Mixed Content

分類Dev

Swift Core Data - arrays not loading properly

分類Dev

Orchard content items not appearing in dashboard

分類Dev

owl carousel in bootstrap modal first time display all images and then owl-carousel work properly

分類Dev

Jquery datatable plugin not loading

分類Dev

Website not loading jQuery

分類Dev

Jquery library not loading correctly

分類Dev

Jquery not loading on ipad

分類Dev

Delay on loading in elements jQuery

分類Dev

Jquery in XPages not working properly

分類Dev

JQuery mask not working properly

分類Dev

Jquery function not executing properly

分類Dev

jQuery show() is not working properly

分類Dev

Next and Prev button will slides 2 items on OWL Carousel

分類Dev

Loading a .NET project with items included as wildcards

分類Dev

Unable to write extracted items properly in an excel file?

Related 関連記事

ホットタグ

アーカイブ