How to Deactivate Navigation Tabs in AnythingSlider?

I am encountering some issues with the css and js while using the AnythingSlider tool. Specifically, I want to modify the navigation tabs in a way that certain tabs will either remain unchanged or become inactive based on a ColdFusion conditional.

For instance, my ColdFusion code might look something like this:

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

The HTML structure of the slider is as follows:

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

I had an idea to create a class "false" for li tags and display one per slide based on the condition (show one if x is true, the other if not).

Essentially, I require assistance in manipulating the CSS to achieve this. The current CSS code for the slider tabs is:

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

UPDATE Despite making changes in the CSS and script at the end of my page, the desired outcome is not being achieved. The tabs are not becoming inactive, and the color is not changing.

I made alterations in anythingslider.css by adding:

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

This script is added towards the end of my main page within 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;

   })

 }
}

Answer №1

To change the color of a tab, you can apply this CSS:

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

If you wish to disable a specific tab, here is a custom function that allows you to enable or disable it. Please note that disabling a tab may affect certain functionalities like hash tags and scripts targeting that panel (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;
   })
 }
}

Usage instructions for the function:

  • If there are multiple AnythingSliders on a page, define the panel variable as shown below with #slider targeting a specific slider:

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

    If there is only one slider, use the shorter variable declaration:

    var panel = $('.thumbNav a.panel' + num);
    
  • To disable a tab, use the following code:

    settab(3, false);
    
  • To enable a tab, use the following code:

    settab(3, true);
    

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Combining JQUERY with Multiple CSS Requests

I have successfully retrieved the following data: var pos = $('div#spotJoinSite').offset(); var width = $('div#spotJoinSite').width(); var height = $('div#spotJoinSite').height(); Can these lines be ...

Update the image source when hovering over the parent element

Check out this snippet of HTML code: <div class="custom text-center threeBox ofsted"> <a class="ofsted" title="ofsted report" href="http://reports.ofsted.gov.uk/"> <img class="text-center ofstedLogo" src="images/ofsted_good_transparen ...

Obtaining the most recent commit date through the Github API

I'm in the process of creating a database containing git repositories and I'm curious about how to extract the date of the most recent commit for a repository listed in my database. My experience with the github API is limited, so I'm strug ...

Attempting to utilize Ajax to save a file in Laravel, however unsure of what may be causing the issue in my code

Looking for a way to save an image file using ajax in Laravel, here is the code I am currently using: Controller public function store(Request $request) { $item = new Item; // if remove $it_files_path , $it_files_name , $path code work co ...

Bring to life by pressing a Trigger button

One of my div elements expands in height when clicked. The jQuery code responsible for this behavior is shown below: $('.contact-click').click(function() { $('#rollout').animate({ height: "375", }, 500); }); ...

Is it possible for Angular.js to interact with JSTL expression language?

Is it possible for angular.js to interact with JSTL expression language? I am trying to generate ng-options using an array. Here is an example of what I am attempting to accomplish: <select ng-model="detail" ng-init="Categories = '${Categories}& ...

What is the method to define YAML array indices in JavaScript?

I apologize for my previous post. I have successfully integrated a RapidAPI for Covid-19 updates, which is now outputting the results as an array JSON in the console. You can view the YAML Array Output here. I am now facing a challenge in listing specifi ...

The length of the notification is determined by the ReadFlag

JS: function fetchNotifications(){ $.ajax({ url: "getgroupednotification.json", type: "GET", crossDomain: true, success:function(response){ ...

What is preventing me from executing this function more than once?

Having this function: const sliderTextChange = document.getElementsByClassName('slider') // text change const changeSliderText = change => { const sliderLeft = document.getElementsByClassName('switch-left') const sliderRight = ...

Leverage the power of Vue Nuxt Auth to activate authentication middleware on a route-by-route

Is there a way to implement auth middleware for individual routes using Class Components? How can I achieve the same functionality as this: <script> export default { middleware: 'auth' } </script> The following method does n ...

Java's equivalent to the return function in JavaScript

Currently, I am in the process of adapting three.js into Java while also incorporating my own modifications and enhancements. One specific challenge I am facing involves determining the best approach for managing reflection within the code. As part of thi ...

Using the same geometric shapes repeatedly leads to occasional texture errors in THREE.JS

As I embark on my journey to create my first card game using THREE.js for Firefox and Chrome, I have encountered a perplexing issue with disappearing textures. The purpose of this post is to gain insights into why this issue occurs and how I can resolve i ...

Fading CSS Background Transition with Responsive Design

One generous member of our online community shared a CSS rollover code that is "fluid" and can adapt to different browser sizes. The code is provided below, along with a link to JsFiddle: CSS .container { width: 100%; height: 300px; backgroun ...

In JavaScript, use a regular expression to replace all instances of %2F with %

Looking for a JavaScript/regex solution to transform %2F into %21. This will allow me to successfully pass forward slashes through a GET parameter after using encodeURIComponent() on a URL. Once the data reaches the server, I'll convert back from ! ...

Achieving the perfect overlay and centered image effect using CSS

I am attempting to design a banner consisting of 3 images, each with dimensions of 900x420, similar to the image shown below. I am looking for advice on how to align these images such that they are horizontally centered. Any suggestions would be greatly ap ...

Tips for generating documentation using markdown within the docs directory on GitHub with the help of JavaScript

After browsing through numerous documentation websites, I have noticed that many of them share the same layout and features. This has led me to question whether there is a common library used by all these documentation sites. How do they achieve this unif ...

Run JavaScript code whenever the table is modified

I have a dynamic table that loads data asynchronously, and I am looking for a way to trigger a function every time the content of the table changes - whether it's new data being added or modifications to existing data. Is there a method to achieve th ...

Iframe displaying a blank white screen following the adjustment of document.location twice

I am in the process of developing a web application that I intend to integrate into my Wix website. The main components of the required web application are a text screen and a button to switch between different screens/pages (html content). However, I am ...

Developing a dynamic comment reply feature using Django, jQuery, and AJAX to create

I am struggling to figure out how to implement a comment reply feature on my blog using Django, jQuery, and AJAX. I need to allow users to leave multiple replies on comments. Can anyone help me solve this issue? Thank you in advance. models.py class Commen ...

Special VueJs rendering for JSON data retrieval from API

Here is the data I received from an API: { "data": { "City": { "zip": "75000", "appointment": { "2020-10-12": { "08:00:00": 3, "09:15:0 ...