views:

38

answers:

1

I'm using the AnythingSlider tool and am having some trouble with the css and js on this. Basically, the slider has a number of navigation tabs that help jump from slide to slide. I want to change this so that when a coldfusion conditional runs, certain tabs will either remain in a default state or become inactive (change color of tab to grey, not let anything happen when user clicks on that tab.)

So basically, my CF would be something like

<cfif #X# is ""> //if true, make tab #2 not clickable, change color to grey
                 //else, if false, keep tab normal.

The slider is basically set up in html like this:

<ul>
    <li></li>  //slide #1
    <li></li>  //slide #2  etc etc
</ul>

I had the idea that maybe I could set up a class li class="false" as an example and have two li tags per 'slide' (show one if x is true, the other if not.)

So, I'm not sure if this makes sense but mostly, I need a hand manipulating the CSS. The code for the slider tabs looks like:

div.anythingSlider.activeSlider .thumbNav a.cur, div.anythingSlider.activeSlider .thumbNav a {
    background-color: #7C9127;
}

UPDATE Well, I don't get it. This is the code at the end of my page (just before ending BODY tag. I threw some alerts in there just to make sure the code runs and it does. But, nothing happens. Tabs don't become inactive and color never changes.

I altered anythingslider.css to include this:

div.anythingSlider.activeSlider .thumbNav a.false,
            div.anythingSlider.activeSlider .thumbNav a.false:hover { background: #555; }

and this is at the bottom of my main page. This script is wrapped in some cfoutput tags:

    <cfif #selected_main_details.X# IS "">
        settab(3, false);
    <cfelse>
        settab(3, true);
    </cfif>

function settab(num, enable){
 var panel = $('.thumbNav a.panel' + num);
 if (enable){
  panel
   .removeClass('false')
   .unbind('click')
   .bind('click', function(){
    panel.closest('.anythingSlider').find('.anythingBase').data('AnythingSlider').gotoPage(num);
    return false;

   })
 } else {

  panel
   .addClass('false')
   .unbind('click focusin')
   .bind('click', function(){                     
    return false;

   })

 }
}
+1  A: 

If you want to just change the tab color, use this css

div.anythingSlider.activeSlider .thumbNav a.false,
div.anythingSlider.activeSlider .thumbNav a.false:hover { background: #555; }

It's a bit more work if you want to actually disable the tab. I put together this function to enable or disable a specific tab. Granted this function will break the hash tag functionality for that tab and it doesn't disable the keyboard or any script that targets that panel - that would require some changes to the plugin (Demo).

function settab(num, enable){
 var panel = $('.thumbNav a.panel' + num);
 if (enable){
  panel
   .removeClass('false')
   .unbind('click')
   .bind('click', function(){
    panel.closest('.anythingSlider').find('.anythingBase').data('AnythingSlider').gotoPage(num);
    return false;
   })
 } else {
  panel
   .addClass('false')
   .unbind('click focusin')
   .bind('click', function(){
    return false;
   })
 }
}

Use the above function as follows

  • If you have more than one AnythingSlider on the page, then the panel variable should be defined as follows with the #slider targeting the specific slider:

    var panel = $('#slider').closest('.anythingSlider').find('.thumbNav a.panel' + num);
    

    if there is only one, then this shorter variable will work

    var panel = $('.thumbNav a.panel' + num);
    
  • Disable the tab as follows:

    settab(3, false);
    
  • Enable the tab as follows:

    settab(3, true);
    
fudgey
Very grateful for this help. However, I couldn't get it to run as suggested. See above for how I implemented it.
stuttsdc
The script is run after you initialize the AnythingSlider correct?
fudgey
yup. I even put the script at the bottom of my page. Didn't seem to matter. I threw a few alerts in there, just to see if the code was running. They popped up but overall there was no effect on the tabs.
stuttsdc
I'm not sure why it doesn't work for you, but I made a demo for you here: http://jsfiddle.net/Mottie/svL2d/ and sorry, I've never used coldfusion so I couldn't tell you if there was something wrong there.
fudgey
Thank you for the demo. It looks and runs as I'd hoped on your page. However, I can not get it to work on my page. I updated my code above to reflect the current state. My Coldfusion is not the issue. I placed some ALERTS in there just to see if the code was actually running and it does. However, nothing different happens on the page at all. I've updated the css, etc. Nothing. I don't get it.
stuttsdc