Created by: codeimpossible
Added support for multiple selections in typeahead. Multiple selection is enabled by either adding a data attr data-mode
or passing an option mode
. I've added examples of both methods below.
Users can specify the delimiter in the data attributes, data-delimiter=";"
, or as an option to the jquery plugin, a default delimiter of ,
is assumed.
If you're using a comma as your delimiter already then you just need to add an attribute data-mode="multiple"
on your input like so to enable multiple selection.
Multiple selection using data attributes
<input class="span5" data-items="10"
data-mode="multiple"
data-provide="typeahead"
data-source="["Catsd","Dogs","Mass Hysteria"]"
id="post_tags"
name="post[tags]" size="30" type="text" value="" />
Multiple selection using jquery plugin
$('.myinput').typeahead({ mode: 'multiple' });