typeahead.js icon indicating copy to clipboard operation
typeahead.js copied to clipboard

using es6 to import typeahead.bundle.js throws 'Bloodhound' of undefined error

Open Gyanxie opened this issue 9 years ago • 5 comments

problem

like this: Uncaught TypeError: Cannot set property 'Bloodhound' of undefined

image

my way

review the code of typeahead.hundle.js , I found "this" is undefined image

change "this" to “window”, it works. image

Gyanxie avatar Jan 06 '17 08:01 Gyanxie

You can add Provider in webpack config plugins new webpack.ProvidePlugin({ jQuery: 'jquery', $: 'jquery', "window.jQuery": "jquery" }),

in source code import typeahead from "typeahead.js"; import Bloodhound from "bloodhound-js";

phuthuycoding avatar Apr 14 '17 06:04 phuthuycoding

@tamanhquyen Thanks! I will try.

Gyanxie avatar Apr 14 '17 06:04 Gyanxie

already have jquery as a provided plugin through webpack.

still can't get past Cannot set property 'Bloodhound' of undefined

thatONEjustin avatar May 14 '18 15:05 thatONEjustin

@thatONEjustin : Can you share your sourcecode ?

phuthuycoding avatar Jun 04 '18 09:06 phuthuycoding

@thatONEjustin I fixed it by adding the bloodhound.js package and using that instead of the one that comes with typeahead. I think that's what @tamanhquyen was suggesting

nickdevereaux avatar Jun 25 '18 05:06 nickdevereaux