Skip to content

Instantly share code, notes, and snippets.

@MartinMalinda
Last active April 25, 2023 10:03
Show Gist options
  • Save MartinMalinda/56f4d44f6a9006930066aed81ad46a83 to your computer and use it in GitHub Desktop.
Save MartinMalinda/56f4d44f6a9006930066aed81ad46a83 to your computer and use it in GitHub Desktop.
<!-- PARENT -->
<script>
const editInvoiceModal = Vue.component({
template: () => vue.h('div', { props: }, [{
vue.h('div', { title: '' }, [
])
}])
});
{
coponents: {
EditInvoiceModal: editInvoiceModal
}
}
</script>
<template>
<div v-for="invoice in invoices">
<button @click="() => editedInvoice = invoice"
<EditInvoiceModal
v-if="editedInvoice"
:invoice="editedInvoice"
@save="(changeObbject) => Object.assign(editedInvoice, changeObject)"
@close="() => editedInvoice = null"
/>
</div>
</template>
<!-- CHILD / EditInvoiceModal.vue -->
<script>
{
data: {
name: null,
dueDate: null,
},
created() {
this.invoiceChange = { ...this.props.editedInvoice };
},
methods: {
saveChanges() {
this.emit('save', {
name: this.data.name,
});
}
}
}
</script>
<template>
<input name="invoiceName" v-model="invoiceChange.name" />
<button @click="saveChanges" />
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment