1.0.2 • Published 4 years ago

bootstrap-tagsinput-plugin v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Bootstrap TagsInput

Tags input for Bootstrap 3

Installation

$ npm install bootstrap-tagsinput-plugin
$ bower install bootstrap-tagsinput-plugin
$ yarn add bootstrap-tagsinput-plugin
$ composer require bootstrap-tagsinput-plugin

Usage example

For example use the input-group:

<div class="form-group">
    <label class="control-label" for="tags">Tags:</label>
    <input id="tags" name="tags" class="form-control" placeholder="Type your tags here..." value="one, two, three" />
</div>

... and init from script:

<script type="text/javascript">
    $(document).ready(function () {
        var tags = $('input#tags').tagsinput({
            delimiter: ','
        });
    });
</script>

Options

NameTypeDefaultDescription
idstringemptyThe widget ID if need.
delimiterstring','Delimiter for split tags.
inputClassstring'.tagsinput'Input class.
labelClassstring'.label .label-info'Tag label class.
autocompletestring/booleanfalseAutocomplete URL.
formatstring"string"Input/output format for autocomplate.
minInputinteger2Min input lenght for add tag.
maxTagsinteger10Max tags count.
templatesarray{inputWrapper, inputField, tagItem etc. }Templates array for widget.
onChangefunctiononChange()The function that is called when input change.
onShowfunctiononShow()The function that is called when widget is ready to be displayed.
onShownfunctiononShown()The function that is called when widget is displayed.
onHidefunctiononHide()The function that is called when widget to prepare for hiding.
onHiddenfunctiononHidden()The function that is called when widget is hidden.
onAddTagfunctiononAddTag()The function is called when a new tag is added to the collection.
onRemoveTagfunctiononRemoveTag()The function is called when the tag is removed from the collection.
onAutocompleteSuccessfunctiononAutocompleteSuccess()The function is called when autocomplete successfully called an ajax request.
onAutocompleteErrorfunctiononAutocompleteError()The function is called when autocomplete caused an ajax error.
onAutocompleteShowfunctiononAutocompleteShow()The function that is called when autocomplete is ready to be displayed.
onAutocompleteShownfunctiononAutocompleteShown()The function that is called when autocomplete is displayed.
onAutocompleteHidefunctiononAutocompleteHide()The function that is called when autocomplete to prepare for hiding.
onAutocompleteHiddenfunctiononAutocompleteHidden()The function that is called when autocomplete is hidden.
debugbooleanfalseFlag if need debug in console log.

Templates

NameTypeDefault valueDescription
inputWrapperstring<div class="bootstrap-tagsinput" />Template for widget wrapper.
inputFieldstring<input type="text" autocomplete="false" />The autocomplete field.
tagItemstring<span class="tag" />The tag template.
tagRemoveLinkstring<a href="#" class="remove" data-dismiss="tag" aria-hidden="true">[x]</a>Link for remove tag.
autocompleteListstring<div class="autocomplete dropdown-menu" />Autocomplete dropdown list.
autocompleteItemstring<li><a class="item" href="#" /></li>Autocomplete dropdown item.

Status and version

  • v.1.0.3 - Added README.md
  • v.1.0.2 - Some bugfixies. Backward compatibility $.ajax for older jQuery version.
  • v.1.0.1 - Added autocomplete.
  • v.1.0.0 - Added base plugin and stylesheets, example.