Wallogit.com
2017 © Pedro Peláez
Composer fork of sliptree/bootstrap-tokenfield
![Build status][travis-badge]
A jQuery tagging / tokenizer input plugin for Twitter's Bootstrap, by the guys from Sliptree, (*1)
Check out the demo and docs, (*2)
Requirements: jQuery 1.9+, Bootstrap 3+ (only CSS), (*3)
dist/bootstrap-tokenfield.js or dist/bootstrap-tokenfield.min.js in your HTMLdist/css/bootstrap-tokenfield.css in your HTML$('input').tokenfield()
You can use the tokenfield:createtoken event for that. Check the event.attrs property for token value and label,
and the run your duplicate detection logic. If it's a duplicate token, simply do event.preventDefault()., (*4)
Here's a simple example that checks if token's value is equal to any of the existing tokens' values., (*5)
$('#my-tokenfield').on('tokenfield:createtoken', function (event) {
var existingTokens = $(this).tokenfield('getTokens');
$.each(existingTokens, function(index, token) {
if (token.value === event.attrs.value)
event.preventDefault();
});
});
Similarly, using tokenfield:createtoken, you can check to see if a token exists in your autocomplete/typeahead
data. This example checks if the given token already exists and stops its entry if it doesn't., (*6)
$('#my-tokenfield').on('tokenfield:createtoken', function (event) {
var available_tokens = bloodhound_tokens.index.datums
var exists = true;
$.each(available_tokens, function(index, token) {
if (token.value === event.attrs.value)
exists = false;
});
if(exists === true)
event.preventDefault();
})
See release notes, (*7)
Previous releases:, (*8)
0.10.0, (*9)
autocomplete="off" to prevent browser-specific autocomplete suggestionstriggerKeys has been renamed to delimiter and accepts a single or an array of characters instead of character codes.0.9.9-1, (*10)
triggerKeys option0.9.8, (*11)
triggerKeys option0.9.7 Valuable, (*12)
prevetDuplicateToken event0.9.5 Typeable, (*13)
0.9.2 Maintenance release, (*14)
0.9.0 Bootstrappable, (*15)
0.7.1, (*16)
0.7.0 Autocompleted, (*17)
0.6.7 Crossable, (*18)
0.6.5 Shiftable, (*19)
0.6 Editable, (*20)
0.5 Initial release, (*21)