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

Tooltip is not defined #244

Closed
Loni2Shoes opened this issue Jan 27, 2017 · 3 comments
Closed

Tooltip is not defined #244

Loni2Shoes opened this issue Jan 27, 2017 · 3 comments

Comments

@Loni2Shoes
Copy link

Loni2Shoes commented Jan 27, 2017

I am having the "Uncaught ReferenceError: Tooltip is not defined" error previously referenced/resolved here:

#172 (comment)

However, the error message persists despite having added the additional entries to my webpack.ProvidePlugin:

plugins: [
        extractCSS,
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery', 
            Tether: 'tether',
            'window.Tether': 'tether',
            Tooltip: 'exports?Tooltip!bootstrap/js/dist/tooltip',
            Alert: 'exports?Alert!bootstrap/js/dist/alert',
            Button: 'exports?Button!bootstrap/js/dist/button',
            Carousel: 'exports?Carousel!bootstrap/js/dist/carousel',
            Collapse: 'exports?Collapse!bootstrap/js/dist/collapse',
            Dropdown: 'exports?Dropdown!bootstrap/js/dist/dropdown',
            Modal: 'exports?Modal!bootstrap/js/dist/modal',
            Popover: 'exports?Popover!bootstrap/js/dist/popover',
            Scrollspy: 'exports?Scrollspy!bootstrap/js/dist/scrollspy',
            Tab: 'exports?Tab!bootstrap/js/dist/tab',
            Util: 'exports?Util!bootstrap/js/dist/util'
        }),
[...]

My bootstrap files loader is:

            { 
                test: /bootstrap[\/\\]js[\/\\]dist[\/\\]/,
                use: [{ loader: 'imports-loader', options: { jQuery: 'jquery' } }]
            }

Naturally, this error disappears if I disable the JavaScript-enabled components in my *.bootstraprc file. I am using version 2.0.0-beta.20 of the bootstrap-loader, version 2.2.0 of webpack, 4.0.0-alpha.6, version of bootstrap. I have tried changing "exports" to "exports-loader" within each of the entries in case it was a webpack 2 difference but without effect (also without an error message being generated).

@Loni2Shoes
Copy link
Author

I was eventually able to resolve this issue. The template my project is based upon includes two different webpack.config.js files (one is for vendor-specific files). I had to put the the entries in my main file, not the vendor file (which already had the aliases for jQuery). I did need to rename exports to exports-loader, like so:

        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
            Tether: 'tether',
            'window.Tether': 'tether',
            Alert: 'exports-loader?Alert!bootstrap/js/dist/alert',
            Button: 'exports-loader?Button!bootstrap/js/dist/button',
            Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel',
            Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse',
            Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown',
            Modal: 'exports-loader?Modal!bootstrap/js/dist/modal',
            Popover: 'exports-loader?Popover!bootstrap/js/dist/popover',
            Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy',
            Tab: 'exports-loader?Tab!bootstrap/js/dist/tab',
            Tooltip: "exports-loader?Tooltip!bootstrap/js/dist/tooltip",
            Util: 'exports-loader?Util!bootstrap/js/dist/util'
        })

@ryannealmes
Copy link

ryannealmes commented Apr 3, 2017

For those that run into this issue, I also ran into this problem because I wasn't initialising my tooltips correctly.

I was doing

componentWillMount() {
  $('[data-toggle="tooltip"]').tooltip()
}

The correct way is below

componentWillMount() {
  $(function () {
    $('[data-toggle="tooltip"]').tooltip()
  });
}

Silly error, but it may help someone.

@abudayah
Copy link

abudayah commented Jan 1, 2018

I'm using Vuejs and this is the solution I've got:

and this is works fine but is there any reason to use dist instead of src ?

webpack.base.conf.js

  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      Popper: "popper.js",
      Alert: 'exports-loader?Alert!bootstrap/js/src/alert',
      Button: 'exports-loader?Button!bootstrap/js/src/button',
      Carousel: 'exports-loader?Carousel!bootstrap/js/src/carousel',
      Collapse: 'exports-loader?Collapse!bootstrap/js/src/collapse',
      Dropdown: 'exports-loader?Dropdown!bootstrap/js/src/dropdown',
      Modal: 'exports-loader?Modal!bootstrap/js/src/modal',
      Popover: 'exports-loader?Popover!bootstrap/js/src/popover',
      Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/src/scrollspy',
      Tab: 'exports-loader?Tab!bootstrap/js/src/tab',
      Tooltip: "exports-loader?Tooltip!bootstrap/js/src/tooltip",
      Util: 'exports-loader?Util!bootstrap/js/src/util'
    })
  ],

in my vue component:

import 'bootstrap/js/src/util'
import 'bootstrap/js/src/dropdown'

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