Is that okay to use Vue.js and jQuery in a single page but each of them handle the different Element(DOM)?

just like the title, is that okay to use Vue.js and jQuery in a single page but each of them handle the different Element(DOM)?

I recently use jQuery. and it become harder to maintaining the DOM since the development has to be growing. I think I should use javascript framework to handle that, like Vue (Vue is recommended because I develop using Laravel for the back-end). But i have some plugins that use jQuery in the same page, but the one that i want to control is not the plugin, but another set of element/DOM in my page. can i do such thing?

Upvotes: 2

Views: 2227

Answers (1)

user6748331
user6748331

Reputation:

Yes, it is OK. Just do not change DOM elements with jQuery directly in elements, which belongs to Vue instance:

<div id="datepicker">
  ...
</div>

<div id="app">
  ...
</div>

<script>
  new Vue({
    el: '#app'
  })
</script>

In this example, change div#datepicker freely, but do not change div#app elements.

BUT... You can change elements in Vue instance also, with jQuery I mean. It is perfectly legal, if you know what you are doing. Just read this "jQuery integration approach" post first, it can direct you how to do it safe way.

Upvotes: 6

Related Questions