Preventing scrolling within a jQuery tab using jQuery

Looking to enhance my jqueryUI tabs by incorporating a smooth scroll bar within each tab. I've experimented with various scrollable plugins such as jQuery custom content scroller, TinyScrollbar, and now areaaperta NiceScroll. However, I continue to encounter the same issue - the scrollbar only functions within one tab.

    <script>
    $(function() {
        $( "#tabs" ).tabs();
    });
    </script>

    <div id="tabs" style="width:900px; font-size:100%;">
    <ul>
        <li><a href="#tabs-1" >FIRST</a></li>
        <li><a href="#tabs-2">SECOND</a></li>
        <li><a href="#tabs-3">THIRD</a></li>
    </ul>
    <div id="tabs-1">
        <div id="thisdiv">
        <p><b>FIRST SCROLLABLE PARAGRAPH</b>...</p></div></div>

    <div id="tabs-2"><div id="thisdiv2">
        <p><b>SECOND SCROLLABLE PARAGRAPH</b>...</p>
    </div></div>
    <div id="tabs-3">
        <p>THIRD TAB </p>
    </div>
</div>

    <script>
    $(document).ready(
  function() {     
    $("#thisdiv").niceScroll({cursorcolor:"#00F"});
    $("#thisdiv2").niceScroll({cursorcolor:"#00F"});  }
);
    </script>

Explore this jsfiddle link which demonstrates the seamless integration between UItabs and two scrollbars of the niceScroll plugin: http://jsfiddle.net/Fluc/EhcqX/4/

Furthermore, I attempted to utilize the same divs with scroll bars within each tab, which you can view at this link: http://jsfiddle.net/Fluc/cJPT3/2/

It's evident that the scrollable feature only functions within the first tab, despite trying various scrollable plugins. I'm not a jquery expert, but it seems like the issue might be related to the display property being set somewhere.

Any assistance on this matter would be greatly appreciated!

Answer №1

This solution is working perfectly. Give it a try and let me know your feedback.

<script>
$(document).ready(function() {
    $("#tabs").tabs();
    jQuery('#tabs').bind('tabsselect', function(event, ui) {    
        ui.tab 
        ui.panel
        ui.index
        if (ui.index==0) {
            $("#tabs-1 > .scrollable").niceScroll({cursorcolor:"#00F"});
        }else if (ui.index==1) {
            $("#tabs-2 > .scrollable").niceScroll({cursorcolor:"#00F"});
        }else if (ui.index==2) {
            $("#tabs-3 > .scrollable").niceScroll({cursorcolor:"#00F"});
        } 
  });
});
</script>

Don't forget to check out the updated version of your fiddle http://jsfiddle.net/cJPT3/9/

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 the jquery-UI slider functionality with the canvas rotate() method

Is there a way to rotate an image using html2canvas plugin and jQuery UI slider? I am new to programming and need some guidance on how to achieve this feature. Here is my current progress: http://jsfiddle.net/davadi/3d3wbpt7/3/ ` $("#slider").slider({ ...

Retrieve the stylesheet based on the presence of a specific class

Is there a way to dynamically add a CSS stylesheet based on the presence of a specific class on a page? For example, instead of checking the time and loading different stylesheets, I want to load different stylesheets depending on the class present in the ...

What is the most effective way to alphabetically organize a Javascript array?

Is there a more professional way to sort people alphabetically by last name in an array? Here is the array I'm working with: const people = [ 'Bernhard, Sandra', 'Bethea, Erin', 'Becker, Carl', 'Bentsen, Lloyd' ...

Guidelines for deploying a node.js REST API application successfully in a production environment

As I venture into the world of node.js apps, I find myself faced with a dilemma. I've created a REST API using node.js that functions perfectly on my local machine. However, when I attempt to build it using webpack, I'm uncertain about how to run ...

Utilizing JQuery for Next and Previous Navigation Buttons

Currently, I am in the process of developing a website where users can click on project images to view detailed information and additional images in a full-screen overlay. I am also implementing next and previous buttons to navigate through the projects. A ...

React: Modifying state does not update useState array

The state of the array does not change when the state change method is called : const [arrayOfDocuments, setArrayOfDocuments] = useState([]); I have tried : setArrayOfDocuments(...[]); or setArrayOfDocuments([]); Where I use my method : const pushToArr ...

The client.postMessage() function in a service worker is not being recognized by the onmessage handler within an AngularJS controller

Handling Service Worker Messages: let angularClient; self.addEventListener('message', function(event) { // store the client that sent the message in the angularClient variable angularClient = event.ports[0]; }); Service Worker Notificat ...

Which one should you begin with: AngularJS or Angular 2?

Interested in learning Angular and curious about the differences between Angular, AngularJS, and Angular 2. Should I focus on educating myself on Angular or go straight to Angular 2, considering it's now in beta version? Is there a significant differ ...

Unable to display the popup modal dialog on my Rails application

I currently have two models, Post and Comment. A Post has many Comments and a Comment belongs to a Post. Everything is functioning properly with the creation of posts and comments for those posts. Now, I have a new requirement where when clicking on "crea ...

An issue occurred while evaluating the Pre-request Script: Unable to access the 'get' property of an undefined object

I need help accessing the response of my POST request in Postman using a Pre-request Script. Script below : var mobiles = postman.environment.get("mobiles"); if (!mobiles) { mobiles =["8824444866","8058506668"]; } var currentMobile = mobiles. ...

Incorporating PHP arrays into JavaScript code within a PDO environment

I'm facing an issue trying to incorporate a PHP array into my JS code and I'm not sure how to resolve it. I found this example (I'm using PDO, not mysqli): Inserting MYSQL results from PHP into Javascript Array $pdo = new PDO('mysql:h ...

Utilize Sass @extend to incorporate imported CSS files in the build process

In my development setup, I have a global CSS file that houses all of the generic CSS styles. My goal is to extend the classes from this global CSS file in any of my SCSS files. However, when I attempt to do so, I encounter an error stating that the .xyz c ...

Attempting to transfer a JSON object from a frontend Form Input to an Express backend

Apologies for bringing up what may seem like a basic issue, but I've been searching extensively (even through axios' documentation) and haven't been able to pinpoint exactly what I need to resolve this issue. I have created a simple To-Do we ...

Difficulty implementing clickable dropdown buttons in a React navbar

After some tweaking, I was able to create buttons that trigger dropdown menus which disappear when clicked off. However, a problem arises when any button is clicked - all of the dropdowns appear at once. It appears that setting the state for one button a ...

Is there a way to add CSS styles to all div elements except for those that are contained within a parent div with a certain class

I have a universal CSS that impacts all div elements, but I need to exclude the divs within a parent div that has a specific class, like in this instance where it's the "should-not-apply" class. div { font-size: 20px !important; font-weight: 50 ...

The menu bar created from getJSON is not displaying the jQuery UI CSS styles as expected

I have been working on creating a jQueryUI menubar using JSON data. The JSON data is successfully being converted into valid HTML, but the menubar does not display with the desired styling. It appears as an unstyled unordered list rather than a styled menu ...

Can I use MuiThemeProvider in my component without any restrictions?

I have a unique component called View: import React from 'react'; import { AppBar, Toolbar } from 'material-ui'; import { Typography } from 'material-ui'; import { MuiThemeProvider, createMuiTheme } from 'material-ui/st ...

Utilizing Jquery Ajax calls to populate a user list on project selection

I am currently utilizing Jira and in need of populating the list of users for the selected project. <td><select id="projectsList" class="textFld" multiple="multiple"></select></td> <td><select id="userList" class=" ...

Change the appearance of a div based on the presence of a certain class within a child div using jQuery styling techniques

I'm trying to set a default padding of 15px for div.content, but if it contains a child div.products-list, I want the padding to be removed. I've looked into solutions using jquery, but nothing seems to work. Here's how my layout is structur ...

Extracting JSON data from a string using jQuery

http://localhost/project1/index.php //AJAX region $(function(){ $.ajax({ type : 'GET', url : 'https://jsonplaceholder.typicode.com/posts/1', success : function(data){ console.log('success \n', data); }, error ...