Tips for disabling modal scrolling on mobile when scrolling the div inside it

Currently, I am facing an issue with a bootstrap modal. I have created a div with overflow:auto inside the modal. Everything works fine on desktop, but on mobile devices, when I scroll the content of the div, the modal itself also scrolls. How can I prevent this behavior and make the modal stay fixed while scrolling the div?

To implement the scrollbar, I am using a plugin called perfectscrollBar.js.

Within my modal body, I have the following div:

<div class="list"><ul></ul></div>

And I add <li></li> elements from JavaScript, resulting in the following structure:

<div class="list">
 <ul>
  <li>Jhon</li>
  <li>Mark</li>
 </ul>
</div>

The CSS for the div with the class list is defined as:

.list {
  height: 70px;
  overflow: auto;
}

So, once the div is populated, it becomes scrollable. The custom scrollbar using perfectscrollBar.js is simply implemented using jQuery:

$(".list").perfectScrollbar();

Answer №1

Shoutout to @RaphaelRafatpanah for providing the perfect solution to my issue!

Check out the Answer Here

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

Creating an input field within a basic jQuery dialog box is not possible

Can anyone assist me in adding an input box to my dialog box? I am working with jquery-ui.js. Here is the code I currently have: $(document).on("click",".savebtn",function(). { var id = $(this).attr("id"); $.dialog({ ...

Printing doesn't display CSS styling

I am currently working on creating a function to change the font color, however, I am facing issues with the CSS when it comes to printing. Here is the code I have: $('#draw').on('click', 'p', function () { if($(this).ha ...

Novice problem with the <div> tag

I am currently in the process of developing a website, and I have encountered an issue with the title not staying within the designated div box at the top of the page. <div style="width:1000px;height:40px;background:grey;border:3px solid;border-radiu ...

Utilizing jquery.load to fill out a form following unsuccessful validation with ajax in CodeIgniter

After exploring numerous form validation tutorials that utilize jQuery Ajax, I have observed a common trend - they all focus on successful form validation. However, my quest is to uncover the process of displaying errors when server-side validation fails. ...

When hovering over a select option, a description and clickable link will be displayed

I need to display a description with a clickable link when hovering over any option in the select tag. <div class="col-lg-4"> <div class="form-group"> <label class="form-label">Goal</label> <select name="semiTaskType ...

Guide on setting the href value within a $.each loop in AJAX requests

I am struggling with downloading a file within a thread. The issue I'm facing is that I can't set the file name in the href and download attributes, so when I attempt to download it, it shows no file available. However, I did realize that replaci ...

What is the best way to send an inline SVG string to my controller?

I am trying to send an inline svg string along with some other properties to my controller. When I replace the svg string with a normal string like "blabla", it successfully reaches my controller. However, with the actual svg string, it never makes it to ...

What steps should be followed in order to write this piece of JavaScript

Upon viewing this post, you will notice an "add comment" link below it. Clicking on this link will add a textarea for users to input their comments. I am curious about how I can implement a similar function? Update: Thank you all for your assistance. I ...

Instructions for creating a table in this specific format

I have some data stored in MySQL and I am looking to display it in a specific format: Data: Name, Image URL, Link I would like to dynamically print it like this: Even though I don't know the user's screen width, I want it to be displayed as w ...

Creating custom styles with makeStyles in Material UI

How can I properly write the following CSS value as a string in a makeStyles function within Material UI? background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.8)), url(../assets/pexels-pixabay-41949.jpg), I attempted to do it this way but i ...

Optimizing Bootstrap Carousel Size

How can I create a carousel using Bootstrap without it taking up the entire window and hiding other div elements? Any suggestions on how to fix this issue would be greatly appreciated. I found this example during my research, but I'm still struggling ...

Issue with jQuery drop down navigation: certain items are not hiding when the mouse moves out of the

My current navigation system consists of a horizontal multi-level drop-down menu using UL elements. While it works well when hovering over items at a moderate pace, speeding up the mouse movement causes issues where items may "stick" in the "show" status a ...

Whenever the ajax oncomplete event is triggered, Primefaces overrides the functionality of jquery, leading to

I have implemented a plugin for fixed table columns in my Primefaces project. The plugin is somewhat functional, but I am facing some issues. primefaces v6.1 jQuery v1.7.1 It works under the following conditions; p:dataTable with <p:ajax event="page ...

When jQuery inserts JavaScript into the DOM, it does not automatically execute the code

UPDATE: I initially used filter(), which was incorrect. I have since switched to find(), but unfortunately the issue persists. This snippet of code functions properly for me: $('#content') .replaceWith($( '<div> <d ...

Issue in Ionic 3 where ion-list does not scroll vertically on iOS devices when ion-items are dynamically generated using ngFor within the ion-list

When using Ionic v3 to develop a hybrid app, I encountered an issue where ion-items within an ion-list generated using *ngFor are not scrollable on iOS devices. Strangely, this problem does not occur on Android devices. Here is the HTML code snippet: < ...

Conceal the div when the horizontal scroll position of the container is at 0

Struggling with a JavaScript issue in a fluid width page that involves scrolling a div using navigation buttons. I am new to JavaScript and trying to use scrollLeft = 0 to hide the leftmost nav button if there's nothing to scroll, and to show the div ...

Show a Pair of Images Upon Submission Utilizing Ajax

Imagine having two separate div containers displayed as shown below: https://i.sstatic.net/qQwjV.png What I achieved was clicking the submit button would upload the image to the designated area. However, my goal is for a single click on the button to loa ...

The website functions perfectly on a local server, but once it's uploaded, the images fail

My website is functioning properly on my computer, however, after uploading it to the server, I noticed that some of the links are not appearing. Upon inspecting these links through developer tools, it shows an image size of 'Natural 1 X 1' despi ...

What is the best way to implement two distinct global CSS styles for separate pages in Next.js?

I'm looking to give my website a fresh look by creating two different global CSS styles. Is it possible to use one CSS style for the old pages and another for the new pages? ...

Crafting a sleek arrow-style stepper with Bootstrap 5 breadcrumbs

I am attempting to create a stepper similar to the one showcased in this instance. To add color to the stepper, I utilized the text-bg-success or text-bg-primary classes on the breadcrumb-item as shown below. However, the spacing between the steps appear ...