[Vuejs]-VueJS detect when DOM is ready after using push() to add a new element

3👍

I’d use a directive for this, as is.

Vue.directive('numeric', {
  inserted(el) {
    $(el).numeric({
      decimal: false,
      negative: false
    })
  }
})

In the template:

<input v-numeric type="text" />

Working pen.

0👍

You can use Vue.nextTick(). https://v2.vuejs.org/v2/guide/reactivity.html#Async-Update-Queue

In order to wait until Vue.js has finished updating the DOM after a
data change, you can use Vue.nextTick(callback) immediately after the
data is changed. The callback will be called after the DOM has been
updated

Leave a comment