[Vuejs]-Jquery is working inside a function but only for one of the calls, the other I must manually execute in the Chrome console

0👍

I wouldn’t recommend mixing jQuery and Vue. Vue uses a virtual DOM while jQuery does not. What’s probably happening is that when the tS function runs, it updates the DOM correctly, but then Vue overrides those changes based on the info it has in its virtual DOM.

See https://vuejsdevelopers.com/2017/05/20/vue-js-safely-jquery-plugin/ for instructions on how to get jQuery to work with Vue. You’re going to have to wrap your jQuery functions in a Vue component which is fine if your needing some complicated functionality in a jQuery plugin, but for basic DOM manipulation like this, it’s much easier to stick to doing this inside of Vue.

Leave a comment