0

First off, I know its bad, if its Vue controlled, then you should control the DOM using Vue. BUT, real life situations are rarely ideal, and in this case, we are migrating an app written in backbone and jQuery, slowly to Vue.

I'm integrating Vue (3) into the existing app, and have Vue control the header, side bar, and creating of main content div, but then the existing app is currently using jQuery to change views and control everything within that content div element. There's tons of jQuery widgets too in the meantime, which we cant simply convert quickly.

Is that ok? Its not great obviously, but can I allow a blackbox situation in there? I will post as new question if I have to, but thought I would ask as related.

I do understand that Vue basically has no control over things within that div, as it doesnt know about it, but would that be ok for now? Can't think of a better way.

I'm already having to do several createApp situations for injecting Vue components into areas within that blackbox, as it seems impossible to do:

Vue root dom (#app)
    -> jQuery/Backbone (#app .contentDiv)
        -> Vue component like a datepicker (.contentDiv. someForm .datePicker)

I'm happy with temporarily doing things that are not GOOD, but not going to be BAD for the operation of Vue. The end goal over the next few months/years is to be fully Vue ofcourse.

redfox05
  • 3,354
  • 1
  • 34
  • 39
  • If there are aspects of your app that are controlled using jQuery in a major way, like a widget, then it is best to isolate all of that behavior into a Vue component, even if all that component does it delegate to jQuery. Then when you want to remove jQuery, you only have one place in your code that you need to modify since the component's interface won't change. – Decade Moon Jun 04 '21 at 10:53
  • Thanks, but that sounds like creating a wrapper for every jQuery widget, of which there are 400+ and have different inputs and outputs. But it sounds like you are more saying this from a code organisational perspective for the future when removing jQuery. I'm looking more for the impact and problems of having contents of a vue component edited from outside Vue. – redfox05 Jun 14 '21 at 17:35

0 Answers0