[Vuejs]-Data in template seems not reactive after updates in Pinia store state

0๐Ÿ‘

You are naming two variables with the same name: v-for="(aWidget, iWidgetNo) in aWidget".

Try to use a different name for the inner loop variable: v-for="(myWidget, iWidgetNo) in aWidget"

0๐Ÿ‘

I changed the way of updating the aWidgets data if it were initially empty

/**
     * Request to create widget
     * @param oParams
     */
    async createWidget(oParams) {
        let oStore = this;
        await oWidgetRequests.createWidgetRequest(oParams)
            .then(function (oResponse) {
                let oCreatedWidget = oResponse.data.data.widget;
                let iWidgetNo = oCreatedWidget.widget_no;
                if (oStore.iWidgetCount === 0) {
                    oStore.aWidgets = {[iWidgetNo]: oCreatedWidget};
                } else {
                    oStore.aWidgets[iWidgetNo] = oCreatedWidget;
                }
                oStore.iSelectedWidgetNo = iWidgetNo;
                oStore.iWidgetCount++;
            })
            .catch(oError => {
                alert('Error\n' + oError.response.data.error.message_key);
            });
    }

Leave a comment