A
A
Alexander Savenko2017-08-17 15:02:58
JavaScript
Alexander Savenko, 2017-08-17 15:02:58

VueJs 2 Ajax request. How can I make the components mount after the data is loaded?

Hello!
The project has a router, 1 main component and 2 child components. Task. Make it so that the data in the child components appears immediately after the data appears in the parent component. The problem is caused by the fact that the jQuery datatable plugin is used in the children and you need to substitute what came from the server into it. There is an option to initialize an empty table, and then, thanks to reactivity, somehow set the data in this table. But how to do that? Which event to use?
<router-view :results="results"></router-view>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Shashenkov, 2017-08-17
@teknik2008

Why use jq at all? Are you having trouble doing sorting and searching on vue?
Here you can see suitable examples
. And about routing and this one here

W
WebDev, 2017-08-17
@kirill-93

After the data appears in the parent component, it can emit an event with $emit and track it in the child element with $on.
In general, vuex is used for data reactivity between components. It is a store of information that gives reactivity.

A
Alexander, 2017-08-17
@boratsagdiev

Pass the data to the child component through props and hang some kind of v-if on the table (like the banal props.length > 0) so that it appears when the data already appears.
Output the data in the table through v-for="props", when the data comes from the server to the parent and from there to the child component, everything will be automatically updated and filled.
I would write in more detail with an example, but it won’t work from the phone :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question