AcceoMKT's avatar

Pass data accross component using vueify

Hi, i am making a pagination for a table using AJAX. At first i did it all in the same component using a main.js with vueify to import it.

However it would be nice to use the pagination again for other type of table so i wanted to extract it in a pagination component.

But, i'm not exactly sure how to do it. Table and Pagination are both children of the Vue app in main.js so using props in Table is not working because Pagination is not a child of him. Also Pagination would need to trigger methods in Table for the AJAX.

So what is the best way to do it? Thanks!

0 likes
1 reply
topvillas's avatar
Level 46

Hold the data for the table and that needs pagination in the root component and pass it into the table and pagination components. Then dispatch events from the components and broadcast them back down from the root.

Either that or use Vuex.

Please or to participate in this conversation.