No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Jqeury as $ in latest quasar version

    Framework
    jquery
    2
    4
    2002
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      genyded last edited by genyded

      In prior Quasar versions, we modified webpack.base.conf.js and added:

      new webpack.ProvidePlugin({
         $: "jquery",
         jQuery: "jquery"
      })
      

      …and all was well.

      In the latest Quasar version, if we add jQuery as a plugin and export as $, node modules that use jQuery as $ error with either ‘$ is not defined’ or ‘$ is not a function’. We also tried setting window.$ and that did not seem to work either.

      Has anyone had any success getting node_modules using jQuery as $ working with the latest quasar (cli as SPA)? Maybe this needs to be done somewhere other than a plugin, but if so where/how?

      S 1 Reply Last reply Reply Quote 0
      • S
        Sujan Dev @genyded last edited by

        @genyded try this

        new (require('webpack')).ProvidePlugin({
                        $: "jquery",
                        jQuery: "jquery"
          })
        
        1 Reply Last reply Reply Quote 0
        • G
          genyded last edited by

          It not the syntax… there is no webpack config file anymore. Everything is done via quasar.conf.js and plugins and there are no clear instructions for how do do domething like this using those.

          G 1 Reply Last reply Reply Quote 0
          • G
            genyded @genyded last edited by

            Not sure if this is the best way, but it works. Create a Quasar plugin (jquery.js or whatever) and put:

            import jQuery from 'jquery'
            
            window.$ = window.jQuery = jQuery;
            
            export default () => {}
            

            Add it to quasar.conf.js:

            ...
            plugins: [
              'axios',
              'jquery'
            ],
            ...
            

            Then anything that references jQuery as $ or jQuery should work anywhere.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post