Z
Z
zorro32020-12-24 17:44:22
JavaScript
zorro3, 2020-12-24 17:44:22

How to save values ​​in a modal tab if the tab has changed?

I wrote a modal window and it has several tabs, when I switch between them, the changes that were made in the tab are not saved. In the data of one of the tabs, I have an object that I use for v-model

data() {
            generalInfo: { policyName: "",  enableLink: false }
        }


<v-switch
                        helpText="help text"
                        class="policy-editor-field policy-editor-field-switch"
                        label="Link to Datasources"
                        v-model="generalInfo.enableLink"
                    />


I track the changes that I make in the generalInfo object and write it to vuex, so that I can then get the data from all the tabs in the main tab and send a request to save the data

watch: {
        generalInfo: {
            handler(val) {
                if (val) {
                    this.setPolicyToEdit(val)
                }
            },
            immediate: true,
            deep: true
        },
    }


But the data is not saved. Please help me how to implement this logic correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-12-24
@zorro3

vue has a cool thing about switching components. Keep-alive. Works great on dynamic components. Look in the docks , maybe this is what you need?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question