E
E
Eka5552017-04-14 12:54:02
JavaScript
Eka555, 2017-04-14 12:54:02

How to call a directive after DOM update in VUE js?

Hello.
I'm trying to implement a list with sorted elements.
So I get a list from the server
this.$http.get('api/pageslist')...

<ul v-sortable>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>


and directive

directives: {
      sortable: {
        bind () {
          console.log('yes')
        }
      }
    }

How can I make the directive be called after updating the DOM ?

If initially the list is inserted into the DOM, then everything is fine.
But is it possible to apply this to elements received from the server?

PS. I know about this.$nextTick() and updated() and can use it.
Just wondering if directives can be applied to elements received from outside.
Thanks everyone!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Eremenko, 2017-04-14
@Eka555

Directives have hooks ( https://ru.vuejs.org/v2/guide/custom-directive.htm... ) that fire on certain events, including when elements and components are updated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question