The recompute of computed elements in Vue data is not being triggered when moving elements in an array

Within my Vue application, I am encountering the following code:

  data: {
      emailData: JSON.parse('#{{@mail.data}}')
  },
  computed: {
      emailJson: function () {
          return JSON.stringify(this.emailData);
      }
  },
  methods: {
      addBlock: function (type) {
          this.emailData.elements.push({type: type, data: ''})
      },
      removeBlock: function (index) {
          this.emailData.elements.splice(index, 1)
      },
      moveBlock: function (direction, index) {
          if (direction === 'up' && index > 0) {
              let temp = this.emailData.elements[index - 1]
              this.emailData.elements[index - 1] = this.emailData.elements[index]
              this.emailData.elements[index] = temp
          } else if (direction === 'down' && index < this.emailData.elements.length) {
              let temp = this.emailData.elements[index + 1]
              this.emailData.elements[index + 1] = this.emailData.elements[index]
              this.emailData.elements[index] = temp
          }
      }
  }

When I execute moveBlock('up',2), the emailData displays the expected changes, but emailJson remains unchanged. However, if I subsequently call addBlock, both the changes introduced by moveBlock and addBlock are reflected in emailJson.

What could be the reason behind addBlock and removeBlock updating the computed value, while moveBlock does not trigger the same behavior?

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

Button react-native press following textInput within scroll view aware of keyboard movements

I'm currently facing an issue where I have a TextInput and a button nested inside a KeyboardAwareScrollView. The goal is for the user to input some text and then tap the button created using TouchableOpacity, which should send the inputted text forwar ...

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 ...

Pass the form data to a Bootstrap modal upon submission of the form

I'm attempting to retrieve form data and convert it to JSON to display in a modal dialog that opens on the Submit button click! This is my progress so far: HTML <form class="form-horizontal" id="configuration-form"> --irrelevant-- <button ...

Creating a series of promises in a structured chain

How can the code structure be improved, especially regarding exception handling within a "promise chain"? $("#save").click(function(e) { e.preventDefault(); let $self = $(this); let profile = {} $self.prop("disabled" ...

The Ajax ResponseText is returning as true but is unable to be written to the div element

Dynamic JavaScript Code: jQuery(document).ready( function($) { var valueCheck; $('#acf-field_5cdc07b87c8f8-field_5cdc08405814f').on( 'change', function () { valueSelect = $(this).val(); if ( parseInt ( val ...

extracting the HTML content from JavaScript and saving it into a standalone file

update When I click a link, a popup opens and I see all this HTML. The smile method is called when I click the link, and we append HTML in that method so that we can see it when the popup is opened. I moved it to a separate file something.component.html, ...

Are you familiar with Vue.JS's unique router options: the 'history' and 'abstract' routers?

Currently, I am developing a VueJS application that involves a 5-step form completion process. The steps are linked to /step-1 through /step-5 in the Vue Router. However, my goal is for the site to return to the main index page (/) upon refresh. One solu ...

Adding a plane to a Three.js scene

When attempting to introduce a plane into the scene, I noticed that nothing is added when checking the children's scene. var newPlane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffff00, opaci ...

I am having trouble converting HTML code to PDF using vue-html2pdf

Currently working on a project in vuejs that requires the use of vue-html2pdf. Interestingly, when I input text within the <section>something</section> tag, my PDF is successfully generated. However, if I attempt to add text inside the <sec ...

NodeJS Socket not transmitting file after connection with client

Having scoured the depths of various resources, including SO and Google, I have hit a roadblock. I am struggling to understand why the socket is failing to capture the uploaded file via the form; it simply stops after connecting. When I check the console, ...

Utilizing Angular Filter to compare the date in a JSON file with the current system date

<p id="appt_time" ng-if="x.dateTime | date: MM/dd/yyyy == {{todaysDate}}">DISPLAY IF TRUE{{todaysDate}} </p> Plunkr:https://plnkr.co/edit/r2qtcU3vaYIq04c5TVKG?p=preview x.dateTime | date: MM/dd/yyyy retrieves a date and time which results in ...

Customize JQGrid formatter for actions - easily edit, save, or cancel without using the default 'action' formatter

Working on an asp.net project, I am developing a page where users interact with a jqgrid version 4.4.4. Due to the limitations of this version, I am unable to use formatter: 'action'. Instead, I have implemented a custom formatter that displays a ...

Change glb files to draco glb in the frontend

Can we encode and transform glb files into draco glb format using only frontend technologies (client side)? ...

Utilizing global enumerations within VueJS

Is there a way to effectively utilize global enums in Vue or declare them differently? My current setup is as follows: Within my types/auth.d.ts: export {}; declare global { enum MyEnum { some = "some", body = "body", o ...

Looking to implement the v-model with a bootstrap-vue b-form-radio on a webpage? Here's how you can

bootstrap-vue When the server side sends me the N categories for radio button groups in JSON format, users will be prompted to rate each category as a priority - high, medium, or low. I need to dynamically generate radio button groups for each category to ...

Executing a controller method in AngularJS when redirecting a page

I am currently working on an app using Cordova/Phonegap, Ionic, and AngularJS. One challenge I am facing is trying to call a method from a controller inside my app when redirecting to another HTML page (secondPage.html). This particular method (secondMetho ...

Add characterizations to object utilizing cropper plugin

After obtaining image attributes from the cropper plugin, I am looking to include two additional values: var data = $img.cropper('getData'); //Object {x: 90, y: 60, width: 720, height: 480, rotate: 0…} image_identifier = $('.image_identi ...

The object displays a value when inspected in the console, but appears as null when checked in the controller (Laravel)

In my form object, I have the following fields: { form: { a: '', b: '', c: '', d: '', e: '', f: '', g: '' } } When I chec ...

Change the color of a c3js chart when it loads

I have been searching for a way to customize the color of a scatter chart's plot, and I came across an example that uses d3 code within the chart http://jsfiddle.net/ot19Lyt8/9/ onmouseover: function (d) { d3.select(d3.selectAll("circle ...

Unraveling and interpreting all incoming requests to my Node.js application

Looking for a simple method to identify and decipher all encoded characters in every URL received by my Node.js application? Is it possible to achieve this using a middleware that can retrieve and decode symbols such as & ? ...