javascript - typeahead.js load error "Uncaught ReferenceError: _ is not defined" - Stack Overflow

oHi guys, on page load i see this error in console:"Uncaught ReferenceError: _ is not defined&quo

oHi guys, on page load i see this error in console: "Uncaught ReferenceError: _ is not defined"

i have this code in head:

<!-- Jquery -->
<script src=".10.1.min.js"></script>
<script src=".2.1.min.js"></script>

<!-- Typeahead -->
<script src="js/typeahead/typeahead.js"></script>

I have no idea whats happening, and i cannot google anything about this kind of typeahead.js problem. I will appreciate any help. Thanks

oHi guys, on page load i see this error in console: "Uncaught ReferenceError: _ is not defined"

i have this code in head:

<!-- Jquery -->
<script src="http://code.jquery./jquery-1.10.1.min.js"></script>
<script src="http://code.jquery./jquery-migrate-1.2.1.min.js"></script>

<!-- Typeahead -->
<script src="js/typeahead/typeahead.js"></script>

I have no idea whats happening, and i cannot google anything about this kind of typeahead.js problem. I will appreciate any help. Thanks

Share Improve this question asked Aug 4, 2014 at 13:46 Michael CeraMichael Cera 1431 silver badge11 bronze badges 2
  • check the network tab of developer tools(F12 > Network) to see if all your scripts are getting loaded correctly – wirey00 Commented Aug 4, 2014 at 13:51
  • Yes, all scripts are loaded correctly. – Michael Cera Commented Aug 4, 2014 at 13:54
Add a ment  | 

3 Answers 3

Reset to default 3

Where did you get your tipeahead script? Looks like it relies on Underscore.js or Lo-Dash

We need more information anyway (stacktrace, how you load the typeahead script, and its content).

I got this error when I was referencing typeahead.bundle.js from the /src/ (source) folder of the bower package instead of the /dist/ (distribution) folder by mistake.

By pointing at the /dist/typeahead.bundle.js instead it works fine without the need to add Underscore.js or Lo-Dash manually.

If you look here you'll see the instructions for installing this library. The _ that it's missing is defined in bloodhound.js. You can see where it is defined in this file around line 6.

Try adding that link before your typeahead script and see if that fixes the problem.

This all may be included with the typeahead script you're loading, which would make my answer wrong, but try it out and see if that fixes it.

Edit: here is the definitions of _ in the github repo

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745286336a4620585.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信