Seeking resolution for slight CSS issue in VueJS drag and drop functionality

I've been working on a VueJS project that requires a drag & drop + nestable feature, as illustrated below. I have made significant progress, but I am struggling with a recursive function issue.

Could anyone help me troubleshoot this? A JSFiddle link is provided below for reference.

UPDATE: I have identified that the problem lies within a CSS issue. Any CSS experts available to assist?

var local = {
  template: '#template-drag',
  name: 'local-draggable',
  props: ['tasks']
};


new Vue({
  el: "#app",
    components: {
        "local-draggable" : local
  },
  data: {
  "tasks": [
    {
      "name": "task 1",
       "tasks": []
    },
    {
      "name": "task 2",
       "tasks": []
    },{
      "name": "task 3",
       "tasks": []
    },
    {
      "name": "task 4",
       "tasks": []
    },
    {
      "name": "task 5",
       "tasks": []
    },
    {
      "name": "task 6",
       "tasks": [
        {
          "name": "task 6.1",
           "tasks": []
        }
       ]
    }
  ]
  },
});
.parent{
  position: relative;
  padding-left: 15px;
}

.dragArea {
  border: 1px dashed;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.dragArea .dragArea > .parent {
  position: relative;
  padding-top: 23px;
  padding-left: 30px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/email-protection#[email protected]"></script>
<script src="https://unpkg.com/email-protection#[email protected]/dist/vuedraggable.js"></script>


<script type="text/x-template" id="template-drag">
   <draggable :element="'div'" :list="tasks" class="dragArea" :options="{group:{ name:'g1'}}" > 
<template v-for="el in tasks" class="parent">
<div class="parent">
<p>{{el.name}} - {{el.tasks}}</p>
<local-draggable :tasks="el.tasks"/>
</div>
</template>
</draggable>
</script>


<div id="app">       
  <local-draggable :tasks="tasks"/>
</div>


For further reference, here is the JSFiddle link: https://jsfiddle.net/minuwan/nb15jd48/

Answer №1

If you want to achieve this, follow these steps.

var local = {
  template: '#template-drag',
  name: 'local-draggable',
  props: ['tasks']
};


new Vue({
  el: "#app",
    components: {
        "local-draggable" : local
  },
  data: {
  "tasks": [
    {
      "name": "task 1",
       "tasks": []
    },
    {
      "name": "task 2",
       "tasks": []
    },{
      "name": "task 3",
       "tasks": []
    },
    {
      "name": "task 4",
       "tasks": []
    },
    {
      "name": "task 5",
       "tasks": []
    },
    {
      "name": "task 6",
       "tasks": [
        {
          "name": "task 6.1",
           "tasks": []
        }
       ]
    }
  ]
  },
});
.parent{
  position: relative;
  padding-left: 15px;
}

.dragArea {
  border: 1px dashed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.dragArea .dragArea > .parent {
  position: relative;
  padding-left: 30px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec9f839e988d8e8089869facddc2dbc2dc">[email protected]</a>"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a0c0f1f1e081b1d1d1b18161f3a48544b4b44896f1c09091018">[email protected]</a>/dist/vuedraggable.js"></script>


<script type="text/x-template" id="template-drag">
   <draggable :element="'div'" :list="tasks" class="dragArea" :options="{group:{ name:'g1'}}" > 
<template v-for="el in tasks" class="parent">
<div class="parent">
<p>{{el.name}} - {{el.tasks}}</p>
<local-draggable :tasks="el.tasks"/>
</div>
</template>
</draggable>
</script>


<div id="app">       
  <local-draggable :tasks="tasks"/>
</div>

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

Utilizing the "row" and "column" attributes in Angular (Flexbox) results in significant spacing between input fields within the HTML code

I'm working on aligning 2 input fields side by side within the same line. To achieve this, I've been utilizing Flexbox. However, I've observed that when using Flex with both 'row' and 'column', it introduces extra spacing ...

Failed to fetch JSON file using jQuery

When I call a web service, I receive a JSON file. I am attempting to retrieve the data using jQuery and display it on an HTML5 page. When I open the JSON file in a browser at SampleURI, I do get the data. {"employeeList":[{"birthDate":"1948-12-08T00:00:00 ...

Using Vue with Firebase to fetch a specific range of data starting from a particular record and ending at the

I am looking to retrieve all records from a certain record to the very last one in my database. ref.orderByChild("date").equalTo("19/11/2020 @ 19:50:29").on("child_added", (snapshot) => { console.log(snapshot.va ...

The issue at hand is that even though the network request is successfully being sent, the expected data is not being returned

Below is a javascript function that I am working with: function test() { jQuery.post("http://www.example.com/test.php", {}) .done(function(data) { alert(data); }) .fail( function(xhr, textStatus, errorThrown) { console.log(xh ...

Incompatibility Issue with Ajax Request on iPad 1 (iOS 5.1.1)

Having an issue with reloading content on my iPad web app. The get request works fine in the browser, but I'm experiencing trouble in Safari on the iPad 1 (iOS 5.1.1). Any suggestions on how to fix this? <script type="text/javascript"> ...

A space designated for numerous receivers

Is there a way to create a field that contains other elements, similar to sending messages to multiple users in a social network? https://i.stack.imgur.com/P9e24.png I attempted to understand the code for this, but it's quite complex. If anyone could ...

Incorporate a button within a listview on Kendoui to trigger the opening of a modal window

I am seeking assistance on how to insert a button on each element of a Listview (PHP/Json) result. When clicked, this button should open a modal window where the customer can input reservation details such as Date, Adults, and Children. Below is the JavaSc ...

Managing URLs for single page applications and Django

I've developed a single-page Vue.js application that utilizes HTML5 History Mode for routing and is served with Django. The urls.py in Django looks like this: urlpatterns = [ url(r'^$', views.home), url(r'^admin/', admin. ...

Change the font weight to bold for the selected item in the Javascript menu, and

I am working on an ASP MVC application that includes a menu with JavaScript functionality to navigate between pages. Currently, when I click on a menu item, it becomes bold and remains bold even when another menu item is selected. This results in all menu ...

What causes the jQuery.easing error to happen when jquery-ui is being used?

After adding dependencies to achieve the add to cart effect in our project, I checked the package.json and found the following installed: "jquery": "^3.4.1", "jquery-ui": "^1.12.1", I then imported these into the co ...

DIY Tooltip jQuery Plugin behaving strangely

Take a look at my code snippet: http://jsfiddle.net/w3kXj/2/ I'm working on a functionality where a checkbox input should reveal the .terms-of-use div on hover. Unfortunately, the behavior of the div is quite unpredictable. There are times when it do ...

What is the reason behind the continual change in the background image on this website?

Can you explain the functionality of this background image? You can find the website here: ...

How can I customize the row background color in a Kendo UI Grid?

Is it possible to set the background color of specific rows in a grid to Light Green? For example, I have a grid with 21 rows and I would like to make rows 1, 5, and 13 have a Light Green background. $("#gridSellIn") .kendoGrid({ width: 15 ...

Having trouble with the JOSN.parse function not functioning properly

Hello there, I'm currently attempting to extract data from a simple JSON string but encountering an error. The object I am trying to retrieve looks like this: { "heading" : "The movies", "box5" : "Click on icon to add text.", "box1" : "At the movies, ...

Input field for change detection

I've been struggling to find a solution to capture the input from Html.TextAreaFor. After trying several options, I found that using a change function only works upon exiting, and employing a keypress event has its drawbacks: it triggers before text ...

AngularJS ng-class feature retains added class without removing it upon change

Within my ng-repeat, there is a text input where I have integrated a date picker that triggers a change event on the input when a date is selected. $(this).val(picker.startDate.format(datePickerOutputFormat)).change(); The AngularJS scope successfully ca ...

Utilize the child array to retrieve the total number in the table

Dealing with JSON data, my task is to count the number of strings within a specific child element and then group them by part of the string to create a table. While this may seem like a confusing and daunting challenge, it's what we need to accomplish ...

Issues with Alignment of Items in Vuetify Data Table Columns

Upon reviewing the code provided, it appears that while the column headers and pagination display correctly (2 pages with 5 records each), all the data is showing in the first column in a jumbled manner. <!DOCTYPE html> <html> <head> ...

What is the best way for Selenium in C# to identify and locate a specific span element by its value

I've been experimenting with different locators, but I'm struggling to find a straightforward solution for identifying the dynamic number within this span using C# Selenium. Initially, my focus is just on locating the span itself. <span inven ...

The background suddenly vanishes once the background-image property is set to no-repeat

I'm currently attempting to add a background image to my WordPress website. .content:before { content: ""; background-image: url("gfx/SevenWonders.jpg"); /*background: #fff;*/ background-size:600px 700px; background-repeat: no-repeat; position: absol ...