login about faq

Hi,

I'm pretty new to jQuery and jQueryUI and I'm eager to try out things. This time, I want to create a content slider than has auto play and can jump to a specific slide. I was able to sort things out for those two rules, but then I want to add a bullet indicator which also replicates the "jump to slide" functionality of #slideNav.

I have tried repeating the same code and attaching a different id (#bullet) but I couldn't get it to work. (I know this would violate web standards- ID uniqueness).

Here's my code:

   <div id="teaseContent">
        <div id="slide-1" class="slide ui-tabs-panel">...</div>
        <div id="slide-2" class="slide ui-tabs-panel">...</div>
        <div id="slide-3" class="slide ui-tabs-panel">...</div>

<ul id="slideNav" class="ui-tabs-nav clearFix">
        <li id="nav-slide-1" class="alpha ui-tabs-nav-item ui-tabs-selected"><a title="..." href="#slide-1">Nav 1</a></li>
        <li id="nav-slide-2" class="alpha ui-tabs-nav-item"><a title="..." href="#slide-2>Nav 2</a></li>
        <li id="nav-slide-3" class="alpha ui-tabs-nav-item"><a title="..." href="#slide-3">Nav 3</a></li>
     </ul>

<ul id="bullet" class="ui-tabs-nav clearFix">
        <li id="nav-slide-1" class="alpha ui-tabs-nav-item ui-tabs-selected"><a title="..." href="#slide-1">#1</a></li>
        <li id="nav-slide-2" class="alpha ui-tabs-nav-item"><a title="..." href="#slide-2>#2</a></li>
        <li id="nav-slide-3" class="alpha ui-tabs-nav-item"><a title="..." href="#slide-3">#3</a></li>
     </ul>

</div>

Here's the head code: (Using jQuery 1.4.2, jQueryUI 1.7.2)

  <script type="text/javascript">
    $(document).ready(function(){   
       //service slide
       $("#teaseContent").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 3000, true); 
    });      
  </script> 

Any ideas on how to make this work? Hope someone could lend a hand and point out some advice :) thanks!

asked Mar 08 '10 at 06:07

voidnothings's gravatar image

voidnothings
17115

edited Mar 08 '10 at 12:32

Randell's gravatar image

Randell ♦♦
1.6k1529

I'm guessing that this isn't your previously working code before the modifications that you're trying to achieve. Could you post the originally working code so we can see if it's really working? Also, you're missing the end quotes on the href attributes of the anchor tags inside li with nav-slide-2 id. Also, you're using the same id for 2 different elements, which would probably cause problems when referring to those elements.

(Mar 09 '10 at 11:04) Randell ♦♦ Randell's gravatar image

Creating a second UL doesn't work because the API doesn't know what to do with it.

If you look at jQueryUI's source, the _tabify function only takes ul:first and does it's jQuery magic on it to turn it into a real tab panel. So aside from messing with jQueryUI, you can just call the select method of the tab directly (note the zero-based index). Is this what you need? This works for me:

<div id="teaseContent">
   <div id="teaseContent-1" class="slide ui-tabs-panel">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
   <div id="teaseContent-2" class="slide ui-tabs-panel">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div>
   <div id="teaseContent-3" class="slide ui-tabs-panel">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>

   <ul id="slideNav" class="ui-tabs-nav clearFix">
     <li id="nav-slide-1" class="alpha ui-tabs-nav-item ui-tabs-selected"><a title="..." href="#teaseContent-1">Nav 1</a></li>
     <li id="nav-slide-2" class="alpha ui-tabs-nav-item"><a title="..." href="#teaseContent-2">Nav 2</a></li>
     <li id="nav-slide-3" class="alpha ui-tabs-nav-item"><a title="..." href="#teaseContent-3">Nav 3</a></li>
   </ul> 

   <ul>
     <li><a href="#" onclick="$('#teaseContent').tabs('select',0); return false;">#1</a></li>
     <li><a href="#" onclick="$('#teaseContent').tabs('select',1); return false;">#2</a></li>
     <li><a href="#" onclick="$('#teaseContent').tabs('select',2); return false;">#3</a></li>
   </ul> 
</div>
link

answered Mar 09 '10 at 11:26

EnderWiggin's gravatar image

EnderWiggin
2324

edited Mar 09 '10 at 11:31

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×18
×10
×2

Asked: Mar 08 '10 at 06:07

Seen: 958 times

Last updated: Mar 09 '10 at 11:31