Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

10. Featuring Content in Carousels and S... > Time for action — adding pagination ...

Time for action — adding pagination controls

Next, we want to set up the function that will create the next button, previous button, and pagination buttons and makes them work.

  1. The jCarousel plugin provides a key called initCallback that will allow us to pass in the name of a function that should be called when the carousel is created. Let's get started by creating an empty function and calling it:
    var slider = $('#featured-carousel');
    function carouselInit(carousel) {
    // Our function goes here
    }
    $(document).ready(function(){
    slider.jcarousel({
    scroll: 1,
    buttonNextHTML: null,
    buttonPrevHTML: null,
    initCallback: carouselInit	
    });
    });
    

    Whatever actions we write inside of our carouselInit() function, it will be executed when the carousel is initialized or set up. Since any page numbers and previous and next buttons would only be functional if JavaScript is enabled, we want to create those buttons dynamically with JavaScript rather than coding them in our HTML. Let's take a look at how we can create a list of page links to each slide in the slider.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint