Passing data from dynamic components as an object to parent component The 2019 Stack Overflow Developer Survey Results Are InUpdate parent model from child component VueVue.js - How to properly watch for nested dataPass data from Component into RootPass data object from parent to child componentVue js dynamic data componentVue.js passing props to a child of dynamic componentVue.js Update child component data from within parentVue how to pass child and parent component data to methodVue.js Child Component emit data into an parent objectVue: How do I render a dynamic component based on parent data?
What do hard-Brexiteers want with respect to the Irish border?
Why doesn't shell automatically fix "useless use of cat"?
Can we generate random numbers using irrational numbers like π and e?
How to translate "being like"?
Pokemon Turn Based battle (Python)
Geography at the pixel level
Match Roman Numerals
Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?
What is preventing me from simply constructing a hash that's lower than the current target?
Why couldn't they take pictures of a closer black hole?
Are spiders unable to hurt humans, especially very small spiders?
How much of the clove should I use when using big garlic heads?
What do these terms in Caesar's Gallic wars mean?
How do I free up internal storage if I don't have any apps downloaded?
What is this sharp, curved notch on my knife for?
"as much details as you can remember"
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
Output the Arecibo Message
How to notate time signature switching consistently every measure
For what reasons would an animal species NOT cross a *horizontal* land bridge?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
APIPA and LAN Broadcast Domain
Passing data from dynamic components as an object to parent component
The 2019 Stack Overflow Developer Survey Results Are InUpdate parent model from child component VueVue.js - How to properly watch for nested dataPass data from Component into RootPass data object from parent to child componentVue js dynamic data componentVue.js passing props to a child of dynamic componentVue.js Update child component data from within parentVue how to pass child and parent component data to methodVue.js Child Component emit data into an parent objectVue: How do I render a dynamic component based on parent data?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have created a form that dynamically renders a group of inputs so I can add and remove that group of inputs depending on how many the end-user needs.
Like this:

I render the "item" inputs using dynamic components:
<component v-for="itemRow in itemRows" :is="itemRow"></component>
The data for the parent looks like this:
components:
ItemRow
,
data()
return
retailer: "",
items: [],
itemRows: ['ItemRow','ItemRow', 'ItemRow'],
date: new Date(),
And the child component:
data() {
return
description: '',
price: 0,
count: 0
So what I want to do is to make an object of the child data and pass that object to the items array in the parent. How can I make that happen?
vue.js
add a comment |
I have created a form that dynamically renders a group of inputs so I can add and remove that group of inputs depending on how many the end-user needs.
Like this:

I render the "item" inputs using dynamic components:
<component v-for="itemRow in itemRows" :is="itemRow"></component>
The data for the parent looks like this:
components:
ItemRow
,
data()
return
retailer: "",
items: [],
itemRows: ['ItemRow','ItemRow', 'ItemRow'],
date: new Date(),
And the child component:
data() {
return
description: '',
price: 0,
count: 0
So what I want to do is to make an object of the child data and pass that object to the items array in the parent. How can I make that happen?
vue.js
add a comment |
I have created a form that dynamically renders a group of inputs so I can add and remove that group of inputs depending on how many the end-user needs.
Like this:

I render the "item" inputs using dynamic components:
<component v-for="itemRow in itemRows" :is="itemRow"></component>
The data for the parent looks like this:
components:
ItemRow
,
data()
return
retailer: "",
items: [],
itemRows: ['ItemRow','ItemRow', 'ItemRow'],
date: new Date(),
And the child component:
data() {
return
description: '',
price: 0,
count: 0
So what I want to do is to make an object of the child data and pass that object to the items array in the parent. How can I make that happen?
vue.js
I have created a form that dynamically renders a group of inputs so I can add and remove that group of inputs depending on how many the end-user needs.
Like this:

I render the "item" inputs using dynamic components:
<component v-for="itemRow in itemRows" :is="itemRow"></component>
The data for the parent looks like this:
components:
ItemRow
,
data()
return
retailer: "",
items: [],
itemRows: ['ItemRow','ItemRow', 'ItemRow'],
date: new Date(),
And the child component:
data() {
return
description: '',
price: 0,
count: 0
So what I want to do is to make an object of the child data and pass that object to the items array in the parent. How can I make that happen?
vue.js
vue.js
edited Mar 8 at 11:01
Laura
8619
8619
asked Mar 8 at 10:55
EmanjoEmanjo
83
83
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Emit an event from the child.
In the parent subscribe to that event
<component v-for="itemRow in itemRows" :is="itemRow" @onChange="updateRow"></component>
You'll also need to pass the index to the child so the parent knows from which element it's receiving the event
<component v-for="(itemRow, index) in itemRows" :is="itemRow" :index="index" @onChange="updateRow"></component>
This means that you need to define a prop on the child component(s).
Remember to update the array using Vue.set/this.$set, otherwise you're array won't be reactive.
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
Thank you so much!
– Emanjo
Mar 8 at 12:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061721%2fpassing-data-from-dynamic-components-as-an-object-to-parent-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Emit an event from the child.
In the parent subscribe to that event
<component v-for="itemRow in itemRows" :is="itemRow" @onChange="updateRow"></component>
You'll also need to pass the index to the child so the parent knows from which element it's receiving the event
<component v-for="(itemRow, index) in itemRows" :is="itemRow" :index="index" @onChange="updateRow"></component>
This means that you need to define a prop on the child component(s).
Remember to update the array using Vue.set/this.$set, otherwise you're array won't be reactive.
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
Thank you so much!
– Emanjo
Mar 8 at 12:59
add a comment |
Emit an event from the child.
In the parent subscribe to that event
<component v-for="itemRow in itemRows" :is="itemRow" @onChange="updateRow"></component>
You'll also need to pass the index to the child so the parent knows from which element it's receiving the event
<component v-for="(itemRow, index) in itemRows" :is="itemRow" :index="index" @onChange="updateRow"></component>
This means that you need to define a prop on the child component(s).
Remember to update the array using Vue.set/this.$set, otherwise you're array won't be reactive.
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
Thank you so much!
– Emanjo
Mar 8 at 12:59
add a comment |
Emit an event from the child.
In the parent subscribe to that event
<component v-for="itemRow in itemRows" :is="itemRow" @onChange="updateRow"></component>
You'll also need to pass the index to the child so the parent knows from which element it's receiving the event
<component v-for="(itemRow, index) in itemRows" :is="itemRow" :index="index" @onChange="updateRow"></component>
This means that you need to define a prop on the child component(s).
Remember to update the array using Vue.set/this.$set, otherwise you're array won't be reactive.
Emit an event from the child.
In the parent subscribe to that event
<component v-for="itemRow in itemRows" :is="itemRow" @onChange="updateRow"></component>
You'll also need to pass the index to the child so the parent knows from which element it's receiving the event
<component v-for="(itemRow, index) in itemRows" :is="itemRow" :index="index" @onChange="updateRow"></component>
This means that you need to define a prop on the child component(s).
Remember to update the array using Vue.set/this.$set, otherwise you're array won't be reactive.
answered Mar 8 at 11:05
Radu DițăRadu Diță
4,33811321
4,33811321
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
Thank you so much!
– Emanjo
Mar 8 at 12:59
add a comment |
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
Thank you so much!
– Emanjo
Mar 8 at 12:59
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
From when do I emit in the child? Using watch to see when something changes in the data properties?
– Emanjo
Mar 8 at 12:29
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
This depends on your use case. You can either watch the data or register to an onchange event on the input fields and fire it from that handler. It all depends on your use case.
– Radu Diță
Mar 8 at 12:31
Thank you so much!
– Emanjo
Mar 8 at 12:59
Thank you so much!
– Emanjo
Mar 8 at 12:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061721%2fpassing-data-from-dynamic-components-as-an-object-to-parent-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown