views:

473

answers:

1

I'm using JQuery and jcarousel, using external navigation controls: http://sorgalla.com/projects/jcarousel/examples/static_controls.html

The problem here is the navigation buttons no longer disable as shown here:

sorgalla.com/projects/jcarousel/examples/static_simple.html

Is there a callback I can use to allow me to swap the active image of a button with an inactive image?

+1  A: 

UPDATED

DEMO: http://jsbin.com/ifomi4/5 SOURCE: http://jsbin.com/ifomi4/5/edit

In responce to your Last comment:

All the code you need ( CSS included ) is in the source, i have commented it so you easy see!

function disableCustomButtons(carousel){

    var prev_class = 'jcarousel-prev-disabled jcarousel-prev-disabled-horizontal';
    if (carousel.first == 1) {
    $('#mycarousel-prev').attr('disabled', 'true').addClass(prev_class);
    } else {
    $('#mycarousel-prev').attr('disabled', 'false').removeClass(prev_class);
    }

    var next_class = 'jcarousel-next-disabled jcarousel-next-disabled-horizontal';
    if (carousel.last == carousel.size()) {
    $('#mycarousel-next').attr('disabled', 'true').addClass(next_class);
    } else {
    $('#mycarousel-next').attr('disabled', 'false').removeClass(next_class);
    }

}

DEMO: http://jsbin.com/ifomi4

SOURCE: http://jsbin.com/ifomi4/edit

The tweek consist of add a proper class to your own NEXT & PREV button like this:

<a class="jcarousel-prev jcarousel-prev-horizontal" href="#">&nbsp;</a>

<a class="jcarousel-next jcarousel-next-horizontal" href="#">&nbsp;</a>

and finally a little of css for have the image at the center of our slider

  /* SET THE MARGIN AS YOU NEED */
  .jcarousel-scroll a { margin: 25px 0 }

This should work as expected! but just see the demo and you got it, i have commented the essential parts!

aSeptik
Strange, I tried to add a comment but it didn't work. I'll try again...I understand how to disable the built in navigation buttons and how to use external controls i.e. controls outside of the list.However, using their example http://sorgalla.com/projects/jcarousel/examples/static_controls.html the controls a simply hyperlinks. I want to retain the image button navigation of the inbuilt buttons including their functionality i.e. change to disabled (greyed out) image when at the start and end.However, I need to do this outside of the list - hence the need for external controls.
see the updates and let me know!
aSeptik
Just to be a real pain, is there any way to have the next and prev button outside of the mycarousel div? The idea is I have a content div that is split into a title div at the top, then a content div underneath. I want the controls to sit in the title div (right aligned) and the carousel in the content div. Currently the controls only work if they are nested in the mycarousel div.as a workaround I've placed the mycarousel and wrap divs outside of my own div container. It needed quite a bit of css modification but the end result looks exactly how I want it :)