Created
July 27, 2012 10:40
-
-
Save eguven/3187381 to your computer and use it in GitHub Desktop.
Twitter Bootstrap comma-separated typeahead
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
$('#autocomplete').typeahead({ | |
source: someDataSource | |
, matcher: function (item) { | |
queryItems = this.query.toLowerCase().split(/, */); | |
queryLast = queryItems[queryItems.length-1]; | |
return ~item.toLowerCase().indexOf(queryLast) | |
} | |
, updater: function (item) { | |
items = this.query.toLowerCase().split(/, */); | |
items.pop(); | |
items.push(item); | |
return items.join() | |
} | |
}) | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment