Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery should not be used with VueJS #13

Open
emahuni opened this issue Feb 24, 2019 · 3 comments
Open

jQuery should not be used with VueJS #13

emahuni opened this issue Feb 24, 2019 · 3 comments

Comments

@emahuni
Copy link

emahuni commented Feb 24, 2019

I have noticed that you use jQuery to hide and show dialogs, however, it is recommended not to since it manipulates the DOM. Besides this, I couldn't even use the component since jQuery doesn't even load. Here is the error:

webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:17 [vue-router] Failed to resolve async component default: ReferenceError: jQuery is not defined
warn @ webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:17
webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:17 [vue-router] uncaught error during route navigation:
warn @ webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:17
webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1898 ReferenceError: jQuery is not defined
    at eval (webpack-internal:///./node_modules/semantic-ui-css/semantic.min.js:11)
    at Object../node_modules/semantic-ui-css/semantic.min.js (:8080/2.js:1969)
    at __webpack_require__ (app.js:767)
    at fn (app.js:130)
    at eval (webpack-internal:///./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./node_modules/semantic-kanban/src/semanticKanban.vue?vue&type=script&lang=js&:14)
    at Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./node_modules/semantic-kanban/src/semanticKanban.vue?vue&type=script&lang=js& (:8080/2.js:115)
    at __webpack_require__ (app.js:767)
    at fn (app.js:130)
    at eval (webpack-internal:///./node_modules/semantic-kanban/src/semanticKanban.vue?vue&type=script&lang=js&:2)
    at Module../node_modules/semantic-kanban/src/semanticKanban.vue?vue&type=script&lang=js& (:8080/2.js:1923)

I am trying to use it in a Quasar Framework app.

Please see my recommendation about your component here, notice the comments about the use of jQuery in Vue. If possible make this Quasar Framework compatible or even a QF component. Quasar has all the dialogs, cards and things you need. A lot of developers consider jQuery deprecated because of modern approaches to reactive designs. This is a very nice component and I would like to see it go far.

Therefore, this issue is related to the use of jQuery instead of VueJS features, Vue actually doesn't want you to do exactly what you are doing; manually manipulate the DOM. Consider using v-show or v-if. Create or use QF dialogs instead of jQuery UI dialogs.

I noticed that your component is utilizing Semantic-UI-css to create dialogs. Anyway, the jQuery fact still remains. Do without it pliz. Consider doing this:

<div class="ui basic modal" v-show="showDialog">
   ....
</div>
// ...
data() {
   return {
       showDialog: false,
   }
},
// ...
methods: {
show () {
   // $(this.$el).modal('show')
   this.showDialog = true
},
hide () {
   // $(this.$el).modal('hide')
   this.showDialog = false
},
}

see no need for jQuery there 🤷🏽‍♂️

@danilosampaio
Copy link
Owner

@emahuni

Replace $(this.$el).modal('hide') with v-show didn't work, becasue semantic-kanban is built using Semantic-UI, and Sematic-UI depends on jquery.

@emahuni
Copy link
Author

emahuni commented Mar 6, 2019

I thought you were using just the CSS part of Semantic UI? In that case you have to change the UI lib you are using because of VueJS. VueJS doesn't need and strongly discourages the use of JQ. It means most projects where this package could be used will not use it because of JQ presence. Developers who are aware of the issues it causes won't even try to use it because of the presence of JQ.

@niallobrien
Copy link

Agreed, a Vue component should not depend on jQuery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants