Add list of options to jquery tags input lib
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I am using this library for tag inputs. I want the user to click and see predefined options instead or in conjunction with typing. This way we can normalize inputs if possible and if not we end up taking their inputs. So I suppose I need 3 states

1-Type anything - as it is now
2-Choose from list
3-Choose from list or type anything

Ideally I end up with an added js file and some added handler for a class to toggle the functions needed. the suggested list wont be long (up to 10 things) so dont worry with managing lots of things here.

Something like ?
tomtoump 7 years ago
if it showed the options as soon as you click, yes
Qdev 7 years ago
awarded to Wikimedia

Crowdsource coding tasks.

4 Solutions

Is this what you want?

Or maybe this this?
tomtoump 7 years ago
The first one is right, now i just need it to work with the tagsinput js lib
Qdev 7 years ago
Why do you want to use that library?
tomtoump 7 years ago
only reason is its already in use in the system im working on and didnt want to end up with multiple tag systems and then have to work out ui differences in them.
Qdev 7 years ago
The thing is that what I posted is a complete solution, for both the tags and the autocomplete.
tomtoump 7 years ago

I think this is what you want .

Have a look at this:

Typeahead is not included in Bootstrap 3, so you'll have to include your own typeahead library. I'd recommed typeahead.js. An example of using this is shown below.

<input type="text" value="Amsterdam,Washington" data-role="tagsinput" />
var citynames = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  prefetch: {
    url: 'assets/citynames.json',
    filter: function(list) {
      return $.map(list, function(cityname) {
        return { name: cityname }; });

  typeaheadjs: {
    name: 'citynames',
    displayKey: 'name',
    valueKey: 'name',
    source: citynames.ttAdapter()

Also, it can fetch remote JSON. Examples are here:

There's also an unofficial port of the Bootstrap 2 typeahead plugin:
( An example )

In xoxco github repo there's an open pull request that should bring in the typeahead support:
dekkard 7 years ago

Here is my solution which aims to meet all your requests: an added js file (which works with that handles the 3 states you want.

you can download the additional js file here. note that it uses jquery-ui's autocomplete plugin so you will have to include jquery-ui.

<!-- jQuery-ui -->
<link rel="stylesheet" type="text/css" href="//" />
<script type="text/javascript" src="//"></script>

<!-- Autocomplete Extension: must be placed after the jquery.tagsinput plugin and before you load any tagsInput({ ... }) -->
<script type="text/javascript" src="tagsinput-autocomplete-extension.js"></script>

download the example to see how it's used.

The issue with this setup is that if there is an update to the tagsinput plugin, and you choose to update, this solution will possibly also need updating. Furthermore, this solution has to do some ugly overriding in order to force tags.

A nicer alternative would be to re-write the tagsinput plugin so that it supports the 3 states you want. However, at that point, you might as well use one of the other tag plugins suggested by tomtoump/laomo/dekkard.

View Timeline