user1288906 user1288906 - 1 year ago 147
Javascript Question

Bootstrap Typeahead.js

I have been trying to get the bootstrap typeahead to work, with no luck whatsoever. I have pasted the code I have. I have reference Jquery-1.9.1 and typeahead.js. What am I doing wrong? Your help is much appreciated! Thanks.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html>
<head id="Head1" runat="server">
<script src="Scripts/typeahead.js-master/test/vendor/jquery-1.9.1.js"></script>
<script src="Scripts/typeahead.js-master/src/typeahead.js"></script>
<input type="text" data-provide="typeahead" autocomplete="off" data-source='["arizona","alaska"]' />

Answer Source

It looks like you're getting confused between typeahead.js (by Twitter) and Twitter Bootstrap's Typeahead feature

You're including the library for typeahead.js

<script src="Scripts/typeahead.js-master/src/typeahead.js"></script>

but trying to use it like Twitter Bootstrap's typeahead feature.

Make sure you're including the Twitter Bootstrap library, if you want to use your current code:

<script type="text/javascript" src="//"></script>

Here's an example: jsFiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download