Epistemologist Epistemologist - 1 month ago 24
Javascript Question

vue js event after rending is done

I have a table that is rendered by Vue. I want to apply datatable on it after it is rendered. Reason I am using Vue first is because its requires lot of custom functionality on each cell.

Whenever I call datatable function on table I get an error because vue is not finished rendering table.

Is there any way to know when Vue is done rendering all elements in a dom so I can apply datatable on it.

Answer

Check out Vue.nextTick()

Here is a sample from the docs:

// modify data
vm.msg = 'Hello'
// DOM not updated yet
Vue.nextTick(function () {
  // DOM updated
})

Reference: http://vuejs.org/api/#Vue-nextTick