How to stop VueJS from exhibiting reactive behavior

Is there a way to utilize VueDraggable to create a cloned item that is completely independent from the original?

You can refer to this fiddle for clarification: https://jsfiddle.net/32f7yu7c/69/

In the provided example, dragging an item from one list to another results in both lists being updated when hitting 'update'. How can I prevent this behavior?

I am looking to modify the click handler

<span @click="update(index)">Update</span>
so that it only updates the item within its respective list.

Answer №1

By default, VueDraggable does not perform a deep clone operation. To achieve this, you must include a 'clone' property in your draggable component, specifying the name of your clone method:

<draggable :list="list" class="dragArea" :clone="clone" :options="{group:{ name:'people',  pull:'clone', put:false }}">

Add the clone method to your component as shown below:

clone: function(me) {
   return JSON.parse(JSON.stringify(me));
}

You can see this functionality in action by visiting the following fiddle link:

https://jsfiddle.net/jmbldwn/3gcyemft/1/

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

continuously repeating css text animation

How do I create an animation loop that slides infinitely, repeating non-stop in full screen without breaking at 'hello5'? I want to display 3 rows of the same item from my items array. Not sure which CSS is causing the issue. The result I am loo ...

Steps to ensure that Vue data is updated to accurately reflect any modifications made by user input in the HTML

I'm currently using Vue to develop a small application that involves copying dynamic HTML content to the user's clipboard once they have completed a form. While everything seems to be functioning correctly, I am encountering an issue where the ch ...

Calling this.$refs.upload.submit() is not providing the expected response from Element-UI

Currently working with element-ui and attempting to upload a file using the following code: this.$refs.upload.submit(); Is there a way to retrieve the response from this.$refs.upload.submit();? I have attempted the following: .then(response => { t ...

Transmit information to a different JavaScript framework using Vue

Utilizing Vue, I create a JSON file using classic ASP from SQL Server and import the data. My objective is to showcase the received data on the page and in ApexCharts. The structure of the HTML page, getData.js, and the JSON from dataSql.asp is outlined b ...

Discovering Vue: Utilizing variables to bind to array keys within components

Is there a way to use variable array keys for bindings in a custom component? For example, how can I make the title 'Title 1 for default settings' if componenttype is set to 'default', and 'Title 1 for guest settings' if compo ...

vuejs function for modifying an existing note

Method for editing an existing note with Vue.js in a web application This particular application enables users to perform the following tasks: Create a new note View a list of all created notes Edit an existing note Delete an existing note Prog ...

Vue.js Enhances CoolLightBox with Multiple Galleries

I am trying to set up a page with multiple galleries using CoolLightBox. It worked fine for me when I had just one gallery, but now that I want to create multiple galleries - each with its own image on the page - it is only displaying one image in the ligh ...

Encountering issues with npm installation on a Linux operating system

Embarking on a new journey learning Vue.js, I find myself in unchartered territory with Node.js. Initially, when I cloned the repository for my course and followed the setup instructions, everything ran smoothly without any issues. However, a blunder on my ...

Why is this component not functioning properly?

I am struggling with making a function to add a component dynamically when I click a button, similar to the code below. However, my attempt at creating a separate method for adding the component instead of using an inline expression is not working. Can som ...

Implementing character limits in VueJS fields

new Vue({ el: '#app', data() { return { terms: false, fullname:'', maxfullname: 10, mobile: '', maxmobile: 10, area: '', maxarea: 12, city: '', ...

Best practices for effectively implementing Vuex getters within the Nuxt Vue Composition API

I have been using @nuxtjs/composition-api(0.15.1), but I encountered some issues when trying to access Vuex getters within computed(). Below is the code snippet using composition API: import { computed, useContext, useFetch, reactive } from '@nuxtjs/ ...

Error encountered during file download with AXIOS: TypeError - 'validateStatus' in blob cannot be searched using 'in' operator

I recently encountered an issue with a Vue app when attempting to download a CSV file using Axios, and I am unsure of how to resolve it. downloadFile: function(res = "") { axios .get('/api/file/' + res, 'blob') ...

The process of mounting a Vue component involves removing the surrounding div element

I am facing an issue while mounting a component on a function. Everything seems to be working fine initially. However, I have configured it to destroy the div after a certain number of seconds. The problem arises when I attempt to add the component again; ...

"Exploring the Power of Vue 3 Event Bus Through the Composition API

I recently set up mitt and I'm facing difficulties dispatching events to another component. The issue arises due to the absence of this in the setup() method, making it challenging to access the app instance. Here's my current approach: import A ...

refresh the localstorage array using vanilla JavaScript

I am attempting to remove an element from an array stored in local storage. I am using vanilla JavaScript within a Vue.js 3 component. Here is my array: ["96", "281", "287", "415", "650", "661", & ...

Is there a way to retrieve the information from the v-text-field without using the v-model directive?

<div v-for="i in parseInt(questionCount)" :key="i"> <v-layout> <v-flex xs6 offset-3 mt-15" > <label for=""> Enter question number {{index}}:</label> <v-text-fi ...

Is there a way to disable a row using ag-grid components?

Recently, while working with ag-grid, I came across documentation on how to disable a column (https://www.ag-grid.com/documentation-main/documentation.php). However, I couldn't find any information on how to disable just one specific row after going t ...

Caution: The Vue Class Based Component is signalling that a property is not defined on the instance, yet it is being

I've been experimenting with creating a Vue component using vue-class-component and TypeScript. I referenced the official documentation here: https://github.com/vuejs/vue-class-component. Despite defining the data within the class as shown below, I en ...

Collaborate on Vue.js components with shared state that dynamically updates when the mouse is moved

Within my Vue.js application, I am faced with a challenge involving two sibling components: a map view and a status bar. The status bar is responsible for displaying various information, including the current geographical coordinates of the mouse pointer. ...

Deploying a Vue.js project for launch

When uploading my Vue.js project to a production server, must I update all the paths for photos, PHP files, and database connection files each time? Is there a more convenient or efficient method available? ...