views:

31

answers:

1

I want the next and prev buttons to have two uses.
First: the standard next and prev through the jcarousel. This I have working. Second, if the user is at the last item in a group, the next button will instead go to the next group.

I have Groups with many Projects

I am running a loop for the projects inside the Group#show view to list the projects in a given group. So when the loop gets to the last project, I would like to change the NExt button into a Next_group button. I know how to write an if statement but I don't know what I am saying if about...

anyone have any ideas? My current buttons:

<a href="#" id="mycarousel-prev"><%= image_tag 'scroll_left.png'%></a>
<a href="#" id="mycarousel-next"><%= image_tag 'scroll_right.png'%></a>
A: 

See the documentation on callbacks. You could use a callback and test to see if the last item visible is the last item in the list.

function mycarousel_itemLastInCallback(carousel, item, idx, state) {
     if (idx == carousel.size) {
          // change your next button into a next_group button
     }
};
ghoppe
Then your saying just place the rails code into the js if statement?thanks
TJ Sherrill
So I am totally a js newb. Learning as fast as I can but, any help is great.function mycarousel_itemLastInCallback(carousel, item, idx, state) { if (idx == carousel.size) { <%= link_to (image_tag 'scroll_right.png'), @next_group %>}};the four parameters: mycarousel, item, idx, state. mycarousel is the carousel div, item would be li? idx is the index and you have that listed and functional, and state would be init and thats where the rails code would go correct?
TJ Sherrill
thanks for the help.
TJ Sherrill