Changing content of inline editable data table in Vuetify through a method

I am facing a challenge while attempting to update the value in my inline edit data table from a method. The issue lies in the fact that the item I pass is not getting updated.

In my cancel method, I pass props.item to be updated. While props.item.iron property is synced, it should still get updated via the edit dialog.

 <template v-slot:item.iron="props">
          <v-edit-dialog
            :return-value.sync="props.item.iron"
            large
            persistent
            @save="save"
            @cancel="cancel(props.item)"
            @open="open"
            @close="close"
          >
            <div>{{ props.item.iron }}</div>
            <template v-slot:input>
              <div class="mt-4 title">Update Iron</div>
            </template>
            <template v-slot:input>
              <v-text-field
                v-model="props.item.iron"
                :rules="[max25chars]"
                label="Edit"
                single-line
                counter
                autofocus
              ></v-text-field>
            </template>
          </v-edit-dialog>
       </template>

Although I attempt to update the provided object, the change does not reflect or pass back up to the model.

   cancel (item) {
      console.log(item)
      item.iron = 'clear'
    }

Is there a workaround to allow me to externally update the prop.item from outside the edit dialog? My primary reason for this is that when a new value is saved, a request is made, but if the request fails, I want to clear the value from the table.

Codepen: https://codepen.io/dicquack/pen/zYxGOQx?editors=1011 Specifically line 116

EDIT: By removing the ".sync" from the v-edit-dialog return value and changing the inner textbox from v-model to :value, I can now modify the value outside the edit dialog. However, I am now faced with another issue where I need to pass the new textbox :value to the edit dialog and then to the save handler.

The CodePen has been updated accordingly.

Answer №1

Make sure to pass the recently modified steel value to the store() function, and include a reference to the updated item, like part (use a unique identifier in a real scenario).

          <v-edit-dialog
            :return-value.sync="data.item.steel"
            large
            persistent
            @save="store({part: data.item.part, data.item.steel})"
            @cancel="cancel(data.item)"
            @open="open"
            @close="close"
          >

In the store() method, make sure to update the steel property within the Data object based on the part field.

store({part, steel}){
// Update the `steel` property in the Data object based on the `part`
}

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

Exploring the capabilities of NodeJS together with the fetch function of Backbone

I have a code snippet for the front-end using fetch: var MyModel = Backbone.Model.extend(); var MyCollection = Backbone.Collection.extend({ url: '/questions', model: MyModel }); var coll = new MyCollection(); ...

Testing XMLHttpRequest with Jasmine: A Complete Guide

Is there a way to test the onreadystatechange function on XMLHttpRequest or pure JavaScript AJAX without using jQuery? I need to do this because I'm working on a Firefox extension. It seems like I may have to use spies, but I'm having trouble bec ...

How can we have a div stay at the top of the screen when scrolling down, but return to its original position when scrolling back up?

By utilizing this code, a div with position: absolute (top: 46px) on a page will become fixed to the top of the page (top: 0px) once the user scrolls to a certain point (the distance from the div to the top of the page). $(window).scroll(function (e) { ...

Using expect() within the .then() function when writing Jasmine unit tests for AngularJS

I'm currently struggling with the .then() function while trying to implement Jasmine unit testing. Here is the code that's giving me trouble: describe("getBuilding", function () { it("checks getBuilding", function () { var id_building = 4; ...

Exploring the concept of ng-model with undefined values in AngularJS

Having an input with a $watch function that updates a search query in real time through AngularJS, I am encountering an issue. Despite setting the initial value of the model to empty, it automatically triggers the search and displays results. My concern i ...

Issues with Imported Routes Not Functioning as Expected

I am currently working on implementing routing in my Angular 2 project. All the components are functioning properly, but I encounter an error when I include 'appRoutes' in the imports section of app.module.ts. An unexpected TypeError occurs: C ...

Utilize the synchronization feature of ES6 Promises in Jasmine with the then/catch method

I have an angular controller that needs to be tested. This controller utilizes a service to fetch data from a server, and the service returns ES6 Promises. function MyController($scope, MyService) { $scope.doSomething = function () { MyService.foo() ...

JavaScript form validation issue unresolved

When I attempt to validate form fields using Javascript functions, they seem to not load or check the field upon clicking the submit button. <html> <body> <?php require_once('logic.php'); ?> <h1>New Region/Entit ...

Choose the specific selector following the current selector

Consider this example of code: <script> $(document).ready(function () { $('span').each(function () { $(this).html('<div></div>') ; if ( $(this).attr('id') == 'W0' ...

How to use the groupBy function in Underscore.js

{ collectionId: 1, category: 'a', collectionType: 'typea' }, { collectionId: 1, category: 'a', collectionType: 'typea' }, { collectionId: 1, category: 'b', col ...

How to assign values to an object within an array in React?

In React, I am currently working on creating a swipeable card that consists of 4 slides. The data displayed within the card is entirely dependent on user input. To start off, I define a sample object like so: const initialState = { id: '', title ...

Guide on applying a filter to the items in a listbox using the input from a text box

In my HTML form, I have the following elements: 1) A list box containing filenames: s1.txt2013 s2.txt2013 s3.txt2012 s4.txt2012 2) A text box where the user enters a pattern (e.g. 2013) 3) A button By default, the list box contains the 4 file ...

A guide on protruding a specific triangle within a mesh using three.js

Description: In my three.js project, I have implemented a selection tool that allows users to click and drag over the mesh to color the triangles red. Now, I am looking to create a function that will examine the mesh.geometry.attributes and extrude any tr ...

What is preventing me from closing modals when utilizing multiple ones at a time?

I'm currently working on setting up a Bootstrap 4 gallery. I want the images to be clickable and open in a larger version. Everything is working fine, but when I introduce multiple scripts, I can no longer close the modals. Here's the code I hav ...

I am interested in creating a class that will produce functions as its instances

Looking to create a TypeScript class with instances that act as functions? More specifically, each function in the class should return an HTMLelement. Here's an example of what I'm aiming for: function generateDiv() { const div = document.crea ...

React: Introducing the latest router feature post-login

I'm facing an issue with the Router in React. After a successful login, I am changing the type state in Redux from 0 to 1. However, when I try to make a switch in my App file, I encounter an error. Warning: [react-router] You cannot change <Router ...

Using Yii2, create a button with an onclick event that executes a JsExpression

I need to submit a form with an array of elements whose number is unknown. class DynamicForm extends Model { /** var string[] */ public elements[]; } In the view where the form submission takes place, I want to include a button that triggers a Ja ...

unable to retrieve element values using class names

I have created multiple h1 elements with the same class names listed below. <h1 class="h1">One</h1> <h1 class="h1">Two</h1> <h1 class="h1">Three</h1> <h1 class="h1">Four</h1> I have also added a button that ...

Having trouble installing Bootstrap using the `npm i bootstrap` command? It seems like the

The npm i bootstrap command is not working when trying to install Bootstrap. Nothing is being added to the packages.json file or node_modules directory. Here are the dependencies listed in the package.json file: "dependencies": { "@angu ...

Methods for transferring data from an AJAX function

I have a database containing various links that I would like to retrieve and store within an array. I attempted to achieve this using the following code: var amz = new Array(); function CreateAmazonArray() { $.ajax({ url: "php/amazon_affilia ...