Login
Home
Eoin Bailey . com
Tech, Research, Code, Work, and Fun
  • Home
  • About Eoin
  • Ph.D.
  • Blog
  • Galleries
  • Training
  • Polls
  • Aggregator
  • Tags
  • Weblinks
  • Site map
  • Contact

Random image

IMG_3398

Tag Cloud

algorithm antarctica apple banking browser code cycle data centre devel Dijkstra drupal drupalcamp economics escapades facebook firefox galway Google greasemonkey iphone ipod livigno theme training weights
more tags

jCarousel and using Images as External Controls

Submitted by Eoin on Mon, 01/02/2010 - 09:31

jCarousel is a fantastic addition to jQuery; it makes it very easy to set up a carousel of images, or indeed text, on your website. It is also a simple matter to add external controls to the system, that allow you to jump between the images and not just scroll: jCarousel external controls example

An issue that came up while putting in an image carousel on a website was how to use images as the external controls. The issue at hand basically arises from this one line:

carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));

This line tells the carousel to use the integer value of the text found at each line that matches the id of our controller as the identifier for where in the carousel that control will move us to. What that means is that the text value of each line has to be a number, usually starting at 1 and increasing, by 1 at a time up to the number of images found in the carousel.

With some relatively simple changes to this line, we can use images with a specific 'alt' attribute and our external controls will still work:

carousel.scroll(jQuery.jcarousel.intval(jQuery(this).find('img').attr("alt")));

Your images must be set up to have the numerical value that image will move the carousel to upon clicked, i.e. in most situations, the first image will have 'alt="1"', the second will be 'alt="2"', etc...

I know this explanation is weak at the moment, I will explain this better and in more detail at a later stage, but right now I have to get my Ph.D. finished. If it is unclear, leave a comment outlining what you don't understand and I'll try to explain.

Bookmark/Search this post with:
  • Delicious
  • Digg
  • StumbleUpon
  • Propeller
  • Reddit
  • Magnoliacom
  • Newsvine
  • Furl
  • Facebook
  • Google
  • Yahoo
  • Technorati
  • Icerocket
  • Eoin's blog
  • Printer-friendly version
  • Send to friend

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.

More information about formatting options

Poll

The Google Nexus One - is it the best phone to date?:

Freelance Work

Some of the websites I have done for others over the years:

  • Studio Richards
  • Medilex
  • Design21C
  • The Spine Clinic
  • Abrivia - Careers and Outplacement
  • Emilie Conway

Training

  • Spinning
  • Hodson Bay Hotel Training
  • Spinning Class - Not too Shabby!
  • Bike Time Trial
  • Spinning Class of Anti-Doom!

Some Links

  • James Bond Opening Scenes
  • Polls
  • Chess Module-Drupal
  • Ski Trip Jan 2009

Recent Comments

  • hey dat was nice
  • Time makes fools of us all.
  • I guess I'll have to update
  • The first one was great but a
  • Cos you're older than you
  • ...
  • page.tpl.php
  • Node vs Page
  • Mid August hit Mollom pretty
  • I don't know of anyone who

Powered by

Powered by Drupal, an open source content management system

Recent blog posts

  • Drupal 'Modules' could be renamed 'Apps'
  • Changes to Domain
  • startPage module Updates - version 0.2
  • Captain Phil Harris
  • Fav4.org - Drupal Module
  • Ebooks - Prices and Sharing
  • jCarousel and using Images as External Controls
  • More Notes on the iPad
  • The iPad
  • QR Code - http://www.eoinbailey.com
more
Copyright © 2010 Eoin Bailey . com.