Search code examples
vue.jsionic-frameworkvuex

vuex store management overwrites the table in ionic


Code: https://github.com/cbsmerveguel/ionicblank

Hi all,

I am very new at vuejs and vuejs with ionic. I wanted to give it a try with a master-detail view, in which at master page a table will be located, and in the detail view the details of the selected item from that table. I am following this youtube video in parallel to do it. The vuex store management worked well, and now I am able to get the details of the selected item, however it came with 2 separate issues:

  1. Right after going in to the detail view and navigating back -> overwrites the table data. As I run the app for the first time, everything is fine. However as I navigate into the second item and navigate back, the first item's inspectionId would be overwritten with the navigated item. Same for any item I am selecting, it keeps overwriting the first item's inspectionId.

enter image description here

After navigating into the 2. item and navigating back to home

enter image description here

  1. Although I am able to get the details of the selected item into the object page, it only displays the inspectionId. Not the Material or Status, these values keep getting picked up from the very first item. enter image description here

Any comment, help would be very much so appreciated.

Code has been shared in the repo: https://github.com/cbsmerveguel/ionicblank


Solution

  • Here is the line of code causing the error.

    data.id = inspectionId is an assignment, so whatever you click becomes assigned to the first object of your tableData array. What you mean to do is a comparison:

    data.id === inspectionId