jcarousel, I need :active state on external controls

Posted by TJ Sherrill on Stack Overflow See other posts from Stack Overflow or by TJ Sherrill
Published on 2010-03-03T06:47:31Z Indexed on 2010/06/16 20:02 UTC
Read the original article Hit count: 402

Filed under:
|
|
|

I am running a Jcarousel and I want to add a.active to the current pagination option. I have seen other posts around about this same thing.
/** * We use the initCallback callback * to assign functionality to the controls */ function mycarousel_initCallback(carousel) { jQuery('.jcarousel-control a').bind('click', function() { carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text())); return false; });

jQuery('#mycarousel-next').bind('click', function() {
    carousel.next();
    return false;
});

jQuery('#mycarousel-prev').bind('click', function() {
    carousel.prev();
    return false;
});
};

// Ride the carousel...
jQuery(document).ready(function() {
jQuery("#mycarousel").jcarousel({
    scroll: 1,
    initCallback: mycarousel_initCallback,
    // This tells jCarousel NOT to autobuild prev/next buttons
    buttonNextHTML: null,
    buttonPrevHTML: null
});
});
</script> 

Thats the initialize code

and the pagination lives inside:
<ul class="jcarousel-control"> <% ([email protected]).each do |n| %> <li><a href="#"> <%= n %></a></li> <% end %> </ul>

Its a rails app, so rails is creating the list based on the number of projects in the group.

Any ideas? Seems like it should be pretty simple.. But I don't know js at all.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery