Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.
/ jquery-tagz Public archive

jQuery plugin that converts standard HTML text input into a cool tag list.

Notifications You must be signed in to change notification settings

dnasir/jquery-tagz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Tagz Plugin

This plugin converts any standard HTML input field into a style-able tag list.

View Demo

This plugin is based on the jQuery Tag Input plugin by XOXCO. The original Github page can be viewed here.

Installation

Include script after the jQuery library (unless you are packaging scripts somehow else):

<script type="text/javascript" src="/path/to/jquery.tagz.js"></script>

Create a HTML input field in your form.

<input type="text" id="tags" />

Initialise the plugin

$('#tags').tagz();

Options

autocompleteOnly

Restricts input field to only accept values generated by jQuery Autocomplete. Requires jQuery Autocomplete to be enabled.

Default value: false

autocompleteOptions

Option values to be passed to jQuery Autocomplete. Please refer to this for valid option values.

Default value: undefined

autosize

Default value: true

comfortZone

Default value: 20

delimiter

Symbol used as separator.

Default value: ','

height

Tag list container height.

Default value: 100

inputPadding

Default value: 12

minChars

Minimum number of characters for tag.

Default value: 0

placeholderColor

Colour of placeholder text.

Default value: '#666'

placeholderText

Text to be displayed in container.

Default value: 'Add a tag'

readonly

Disables input. Useful for displaying input tag list.

This value is overridden if the HTML input field has the disabled attribute.

Default value: false

removeWithBackspace

Allows tag remove using backspace. Set to false to disable.

Default value: true

showInput

Shows the original HTML input field.

Default value: false

unique

If set to true, no duplicates are allowed.

Default value: true

width

Tag list container width.

Default value: 300

Methods

addTag

$(selector).tagz('addTag', 'New Tag');

Append a new tag to the tag list.

Returns matching DOM element if single, array of matching DOM elements if multiple.

removeTag

$(selector).tagz('removeTag', 'New Tag');

Removes an existing tag from the tag list.

Returns matching DOM element if single, array of matching DOM elements if multiple.

destroy

$(selector).tagz('destroy');

Destroys the instance and restores the elements back to pre-init state.

Returns matching DOM element if single, array of matching DOM elements if multiple.

tagExist

$(selector).tagz('tagExist', 'Tag to check');

Checks if tag exists in tag list. Only works when used with single DOM element. Multiple DOM elements will return an array of matching DOM elements.

Returns boolean true if tag exists, and false if not.

Events

onReady

Fires when instance is ready.

$(selector).tagz({
    onReady: function(){
        // do something
    }
})

onDestroy

Fires when instance is destroyed.

$(selector).tagz({
    onDestroy: function(){
        // do something
    }
})

onAddTag

Fires when a tag is added.

$(selector).tagz({
    onAddTag: function(addedTagValue){
        // do something
    }
})

onRemoveTag

Fires when a tag is removed.

$(selector).tagz({
    onRemoveTag: function(removedTagValue){
        // do something
    }
})

onChange

Fires when tag list is changed.

$(selector).tagz({
    onChange: function(newTagList){
        // do something
    }
})

About

jQuery plugin that converts standard HTML text input into a cool tag list.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published