简体   繁体   中英

Twitter-Bootstrap typeahead not working

I'm having some trouble getting the typeahead working in Bootstrap, and I've boiled the problem down to this short example. (I'm new to Bootstrap.) When I type in the input, no typeahead suggestions appear. Any ideas why this isn't working?

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <label for="primaryCustName">Name:</label>
            <input type="text" data-provide="typeahead" data-source="['Bob','Jim','Sue']" class="form-control" id="primaryCustName">
        </div>
    </body>
</html>

The typeahead function was removed from Bootstrap in v3. According to @mdo it was dropped "in favor of folks using Twitter's typeahead. Twitter's typeahead has more features than the old bootstrap-typeahead.js and less bugs."

Your two options from here are:

  1. Use a port of Bootstrap v2 Typeahead, you can find one here .

  2. Use Twitter Typeahead which can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM