1👍
Update: as per Estus Flask’s comment I have got the desired result.
outerHTML disables reactivity
I have done following changes to my code
- Made the pageNuber a ref()
- adjusted the slice & pagination controls for the pageNumber ref
- return vm.$el instead of vm.$el.outerHTML
export function createInfoBubble(args, pageNumber = 1) { const itemsPerPage = 1; const currentPageNumber = ref(pageNumber); function changePage(newPageNumber) { if ( newPageNumber >= 1 && newPageNumber <= Math.ceil(args.length / itemsPerPage) ) { currentPageNumber.value = newPageNumber; } } ... args .slice( (currentPageNumber.value - 1) * itemsPerPage, currentPageNumber.value * itemsPerPage ) .map((item, index) => { ... { onClick: () => changePage(currentPageNumber.value + 1) }, .. return vm.$el;
Source:stackexchange.com