Bootstrap Tags Input
Query plugin providing a Twitter Bootstrap user interface for managing tags
Examples
Markup
Just add
data-role="tagsinput"
to your input field to automatically change it to a tags input field.statement | returns |
---|---|
$("input").val() |
|
$("input").tagsinput('items') |
|
True multi value
Use a
<select multiple />
as your input element for a tags input, to gain true multivalue support. Instead of a comma separated string, the values will be set in an array. Existing<option />
elements will automatically be set as tags. This makes it also possible to create tags containing a comma.statement | returns |
---|---|
$("select").val() |
|
$("select").tagsinput('items') |
|
Typeahead
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.statement | returns |
---|---|
$("input").val() |
|
$("input").tagsinput('items') |
|
Categorizing tags
You can set a fixed css class for your tags, or determine dynamically by provinding a custom function.
statement | returns |
---|---|
$("input").val() |
|
$("input").tagsinput('items') |
|
Options
option | description | |
---|---|---|
tagClass |
Classname for the tags, or a function returning a classname
| |
itemValue |
When adding objects as tags, itemValue must be set to the name of the property containing the item's value, or a function returning an item's value.
| |
itemText |
When adding objects as tags, you can set itemText to the name of the property of item to use for a its tag's text. You may also provide a function which returns an item's value. When this options is not set, the value of
itemValue will be used.
| |
confirmKeys |
Array of keycodes which will add a tag when typing in the input. (default: [13, 188], which are ENTER and comma)
| |
maxTags |
When set, no more than the given number of tags are allowed to add (default: undefined). When maxTags is reached, a class 'bootstrap-tagsinput-max' is placed on the tagsinput element.
| |
maxChars |
Defines the maximum length of a single tag. (default: undefined)
| |
trimValue |
When true, automatically removes all whitespace around tags. (default: false)
| |
allowDuplicates |
When true, the same tag can be added multiple times. (default: false)
| |
freeInput |
Allow creating tags which are not returned by typeahead's source (default: true)
This is only possible when using string as tags. When itemValue option is set, this option will be ignored.
| |
typeahead |
Object containing typeahead specific options
| |
source |
An array (or function returning a promise or array), which will be used as source for a typeahead.
| |
onTagExists |
Function invoked when trying to add an item which allready exists. By default, the existing tag hides and fades in.
|
Methods
method | description |
---|---|
add |
Adds a tag
|
remove |
Removes a tag
|
removeAll |
Removes all tags
|
focus |
Sets focus in the tagsinput
|
input |
Returns the tagsinput's internal <input />, which is used for adding tags. You could use this to add your own typeahead behaviour for example.
|
refresh |
Refreshes the tags input UI. This might be usefull when you're adding objects as tags. When an object's text changes, you'll have to refresh to update the matching tag's text.
|
destroy |
Removes tagsinput behaviour
|
Events
event | description |
---|---|
beforeItemAdd | Triggered just before an item gets added. Example:
|
itemAdded | Triggered just after an item got added. Example:
|
beforeItemRemove | Triggered just before an item gets removed. Example:
|
itemRemoved | Triggered just after an item got removed. Example:
|
For a change, there is an article that focuses on a specific topic and is not all over the places. I like the fact that it is actually problem-solving and not just random and baseless subject. Great going!
ReplyDeletekhalsa kirpan price
kolkata based online shopping site
male kurta dress
sikhvivah
hari singh nalwa photo
silver chattar online
punjabi pagri colours
ladies kurta chadra
kabaddi list
sikh boys for marriage
sikh turban dastar
online male kurta shopping
punjabi kada heavy
gatka warriors
sahib order online
punjabi kalire online shopping
muktsari kurta pajama with jacket
punjabi kada online buy
punjabi lok geet punjabi lok geet
sardar pagri online
artificial accessories online
sardar pagri house