views:

354

answers:

1

First as a note I am using this plugin in a Rails app. Ok I need to do two things.

The first is that the pagination that I have working through:

 jQuery('.jcarousel-control a').bind('click', function() {
    carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
    return false;
 });

needs to work without text. right now if I run a basic loop:

<%  ([email protected]).each do |n| %>
<a href="#"><%= n %></a>
<% end %>

It prints 3 numbers (I have three projects available to the loop), 1 2 3. Inside the links those numbers work for navigating between the projects. But I would like to replace the number with a graphic:

<a href="#"><%= image_tag 'empty_circle.png' %></a>

that way there is a graphical representation of the pagination. Is there a way to change the javascript to accept a non-numbered/image for pagination?

The second thing I need to do is create a "current" css rule, where if its current it would load a different image

<a href="#"><%= image_tag 'full_circle.png' %></a> . 

thanks for any help you can provide. I am pretty new to rails and other than plug and play I am very new to js and jquery.

+1  A: 

Don't have time to write it out but one way of doing this might be something like:

  • Change the main jquery selector to point to the image.
  • Change the jquery page number to point to something like the link rel tag wrapping the image instead of its "text".
  • Load the page number into the rel tag with PHP (or manipulate it with jquery, depending on what you need) from which it is then read.
  • Put the different pagination images into a single large "imagemap" and use jquery to move the background position to the one you need. This way all those images get loaded on first page load and you don't need to fetch anything or hide the images. You need to add this line into your jquery function when the click takes place.

Hope that makes sense/helps.

Tom
makes sense but I have no idea how to do it. sorry for being a newb... trying to learn though... thanks for the help.
TJ Sherrill
TJ ... no prob, it's quite a lot of hassle for that nice little touch, so if you feel it's a stretch, I'd suggest thinking about whether you can live without it.
Tom
using Rails I can setup the rel pretty easy, but I have no clue how to point the javascript to the rel... thanks for the help man.
TJ Sherrill
You can grab it like this: var x = $("ELEMENT").attr('rel'); (ELEMENT is the element you need) and I think you can refer to it like this: $("ELEMENT[rel=3]").doSomethingHere ... and if it's variable then: $("ELEMENT[rel="+var+"]").doSomethingHere
Tom
If anyone else has any thoughts I'd love to hear... thanks tom/.
TJ Sherrill