georgiadogs
01-27-2010, 12:33 AM
I'm using "Coda-Slider 2.0 (http://www.ndoherty.biz/tag/coda-slider/)" for a tab-based interface. I used external triggers to switch between tabs, and I'm having trouble adding my "selected" class when I click on one of the triggers.
It works...BUT...it takes two clicks for it to respond correctly. The slider works just fine, but the "selected" class isn't added (i.e. the selected tab gets a different background image) until I click on one of the menu items twice. Here is the JavaScript I used:
$("a").click(function(){
$(".menu a.selected").removeClass("selected"); // remove previous class if there is any
$(this).addClass("selected"); // add class to the clicked link
return false; // prevents browser from following clicked link
});
And here is the HTML. The "xtrig" class is required for it to be used as an external trigger for the slider.
<ul class="menu">
<li class="day1"><a class="selected xtrig" href="#1" rel="coda-slider-1">Day 1</a></li>
<li class="day2"><a class="xtrig" href="#2" rel="coda-slider-1">Day 2</a></li>
<li class="day3"><a class="xtrig" href="#3" rel="coda-slider-1">Day 3</a></li>
<li class="day4"><a class="xtrig" href="#4" rel="coda-slider-1">Day 4</a></li>
</ul>
Any ideas why it would take two clicks for it to function? Thanks!
It works...BUT...it takes two clicks for it to respond correctly. The slider works just fine, but the "selected" class isn't added (i.e. the selected tab gets a different background image) until I click on one of the menu items twice. Here is the JavaScript I used:
$("a").click(function(){
$(".menu a.selected").removeClass("selected"); // remove previous class if there is any
$(this).addClass("selected"); // add class to the clicked link
return false; // prevents browser from following clicked link
});
And here is the HTML. The "xtrig" class is required for it to be used as an external trigger for the slider.
<ul class="menu">
<li class="day1"><a class="selected xtrig" href="#1" rel="coda-slider-1">Day 1</a></li>
<li class="day2"><a class="xtrig" href="#2" rel="coda-slider-1">Day 2</a></li>
<li class="day3"><a class="xtrig" href="#3" rel="coda-slider-1">Day 3</a></li>
<li class="day4"><a class="xtrig" href="#4" rel="coda-slider-1">Day 4</a></li>
</ul>
Any ideas why it would take two clicks for it to function? Thanks!