The stack feature in jquery-ui 1.9.2 will reset the z-index of a draggable div

I am facing an issue with my dynamically generated divs that have a z-index of 120 set in the CSS:

.plugin {
        position: absolute;
        z-index: 120;
    }

These divs consist of a title (positioned on top) and a canvas:

.plugin_title {
        font-size: 13px;
        color: rgba(255, 255, 255, 0.9);
        font-family: arial;
        background-color: #300;
        z-index: 150;
    }
.plugin_canvas {
        position: relative;
        background-color: black;
        border: 1px solid #300;
        border-bottom-right-radius: 5px;
        z-index: 120;
    }

Upon creation, I do the following:

var div = $( '<div class="plugin ' + audioclass + '" id="'+ id + '"</div>').width(width + 2).height(height + 2);
var ctx = $( '<canvas class="plugin_canvas" width="' + width + '" height="'+ height + '" />', {width: width, height: height} );
var title = $( '<div class="plugin_title"> ' +name + ' </div>');
title.appendTo(div);
ctx.appendTo(div);
div.appendTo('#plugin_area');

Then I call jsplumb.draggable to make them draggable using JSPlumb's implementation of jQuery's .draggable():

jsPlumb.draggable(div, {cursor: "move", handle: title, opacity: 0.9, stack: ".plugin", scroll: true})

The problem arises when dragging a .plugin div; its z-index gets reset to 1 and incrementally increases due to the stack option. I want the z-index to start from 120 and increase accordingly.

In jqueryui 1.7, there was a min parameter for the stack option which is no longer available in the version 1.9.2 that I use. It should supposedly start stacking from the existing z-index value but seems to restart arbitrarily at 1. What could be causing this discrepancy?

(Using jsPlumb 1.3.16, jquery-ui 1.9.2, jquery 1.8.1. Unable to revert to an older version of jquery-ui)

Answer №1

Resolved through

$(".plugin").each(function() {
            // Be sure to always include a radix with parseInt
            var index_current = parseInt($(this).css("zIndex"), 10);
            if((20 - index_current) > 0) {
                $(this).css("zIndex", 20 + index_current);
            }
        });

A bug was also identified and fixed in jqueryUI at this link.

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

The hyperlink is unclickable because of the menu

The code below contains a menu on the right side with a hover effect and some content with a link. However, the link is not clickable due to the menu. .menubar{position: fixed;right:0;top: 50%;transform: translateY(-50%);-webkit-transform: translateY(-5 ...

Understanding the float feature in CSS

Why is there an empty space to the left of the image in my code section? #features{ background-color: #f9f6f7; } .featuresimg{ width: 40%; float: left; } <section id="features"> <img class="featuresimg" src="https://via.placeholder.com/ ...

Can theme changes be carried over between different pages using Material UI?

I've encountered an issue with MUI 5.14.1 where I'm getting an error every time I attempt to save themes across pages using localStorage. Any suggestions on how to resolve this problem or recommendations on a different approach would be greatly a ...

Tips for incorporating a tooltip into a disabled selectpicker option

A selectpicker I have is filled with various languages, listed as `li` tags within a `ul` tag. You can see an example in the image provided below. https://i.stack.imgur.com/dsg66.png It's noticeable that the `+ Add Language` option in the selectpick ...

What steps should I take to incorporate dark mode into my current SCSS and Angular configuration?

I am currently utilizing Angular 13 and SCSS in my project. My goal is to incorporate Dark Mode for the application, here is my existing setup. _variables.scss $body-color: #f0f0f0; :root { --body-color: #{$body-color}; } Throughout the application, i ...

Why is there a mismatch between CSS and Angular 6 selector components?

website.html <website-chat></website-chat> chat-page.html <h1>Greetings</h1> chat-script.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'website-chat', templateUrl: '. ...

Animation will begin once the page has finished loading

On the website, there is a master page along with several content pages. The desired effect is to have a fade-in animation when navigating between pages. Currently, when clicking on a link, the new page appears first and then starts fading out, but this sh ...

Guide on placing an <img> within a navigation bar

I am currently working on a Bootstrap 4 navbar that includes both a logo and text in the navbar-brand section. However, I am facing difficulties in positioning the brand-logo and text accordingly. <!doctype html> <html ...

Responsive dropdown menu in Bootstrap 5 navbar

Update: I successfully fixed the desktop version. Now, I just need to work on making it responsive for mobile. The problem I am encountering is that the dropdown menu doesn't function properly on both mobile and desktop. Although the styling looks go ...

When implementing the "box-sizing: border-box" reset, the layout may become distorted if the image height is specified in percentage

I am facing an issue with my header containing a logo when I apply the box-sizing: border-box reset. Here is the functional header: .header-container { height: 60px; width: 100%; background-color: #333333; color: white; display: flex; justif ...

Ways to find the image source using JavaScript/Jquery upon page loading?

I've scoured countless forums, yet a viable solution still eludes me. My objective is simple - upon page load, I want to gather all elements with the ".home" class and store them in an array called arr. Subsequently, the script should iterate through ...

What is the purpose of using multiple css classes together?

In my project, I have implemented CSS modules which allow me to use multiple classes. The variable open is a boolean that determines whether or not the Paper should shift. <Paper className={`${classes.paper} ${open && classes.paperShift}`}> Questio ...

Animating CSS styles in Vue.js based on JavaScript triggers

Within my Vue.js application, I've implemented a login form that I'd like to shake whenever a login attempt fails. Though I have achieved the desired shaking effect, I'm not completely satisfied with my current solution. Here's a simpl ...

What is the best way to maintain the position of an overlay on screen when dealing with multiple resolutions?

I'm struggling to find a solution that works for me - I could really use some assistance. My CSS skills are not up to par... Currently, I have a video embedded in a web page with a text overlay. The problem arises when the content is displayed on a l ...

Clicking the mouse will eliminate the input's focus

I have an input element with type radio. When the element receives focus via keyboard, it should display a focus style, but when accessed via mouse click, the focus should be removed. I want to achieve this without using JavaScript or jQuery. This element ...

The Font Awesome icons are failing to load properly and are displaying as square boxes in HTML

After cloning the website from HTTRACTs, I noticed a problem with the icons such as Facebook and Instagram appearing as squares on the entire pages. Upon inspecting the elements, I found that the error log was showing Failed to load resource: net::ERR_FILE ...

Placing buttons on top of a video within a div container

I am facing a challenge with implementing custom controls on a video embedded in my webpage. I have tried setting a div to absolute position for the buttons, but they are not clickable. Is there a way to achieve this without using jQuery? I need the butto ...

"Utilize input within the div element to occupy the entire cell of the

There is a form input enclosed within a div which is nested inside a table cell. <td align="left" id="subformAttachments_Htmltable1td10" style="border:solid 1px black;width:316px;" class="tbldroppable ui-droppable ...

"Encountering an issue with the live preview feature in Br

Currently, I am working on a project offline and trying to make Brackets' live preview feature work smoothly. It has proven to be quite convenient for my tasks. While opening my project files using the "open file" option in Brackets, I encountered an ...

Creating a full-width header in React: A step-by-step guide

I'm facing an issue with the header I created - I want it to be 100% width of the screen, but when I decrease the screen size, it doesn't scale accordingly. Here's my current CSS: <Box style={{ backgroundColor: "RGB(46 ...