Why doesn’t my update dialog see updated values in form?

I am developing a demonstration app in Vue 3 and Vuetify 3 and Pinia so that I can learn the main techniques of working with Vuetify. My app displays a list of transactions and provides a form for adding new transactions. That much is working fine. I’ve added buttons to delete a transaction (which also works fine) and to update an existing transaction but that one does NOT work correctly.

The update button correctly displays the current values in the transaction, makes the key read-only (since the key itself should never change) and makes the other values accessible for updating. The edits on the updateable fields work fine. However, when I inspect the validated input prior to updating them, the values are the original ones, NOT the updated ones. I know I’m doing something fundamentally wrong but I’m not quite sure what it is.

Here’s a playground to demonstrate the problem.

  1. Make sure you’ve turned on Developer Tools so that you can see the console.log.
  2. Click on the yellow button with the black pencil icon in any row of the table to bring up the Update dialog.
  3. In the Update dialog, change any one or more of the Description, Transaction Type, or Amount.
  4. Press the UPDATE TRANSACTION button.
  5. Watch for the console.log messages that display the values of updated Description, updated TransactionType, and updated Amount. Regardless of what updates you did, only the original values are shown; the values you changed on the form do NOT appear.
    I thought that the values of the three fields, Description, Transaction Type, and Amount, were found in :model-value. In other words, the initial value of the form field is what is in :model-value at the time the form is first displayed and that when one of the form fields is changed, the new value could also be obtained from :model-value but that doesn’t appear to be true because that’s where I’m trying to get the amended values. What am I misunderstanding?

If you want a local state in the modal (or, should I say, if you want to only apply the changes on confirmation), you have to break reactivity and create a local item variable in the modal, which holds the changes without applying them to model. Only when the confirmation button is pressed you copy item into model.

Also, you want to update the item in items array, not the one in selectedItemUpdate. You do that in a function, which:

  • updates the item when the modal updates the value and
  • sets selectedItemUpdate to null, which closes the modal. This has to be done in parent component, not in child. If you do it in child, and apply the change, the table row becomes null.

See it working here.

Note: I’ve only fixed the update modal’s logic, you have to implement the same logic for the delete modal.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật