A Javascript library for managing tags.
Add the required files to your web page <head>
.
<link href='hardtack.css' rel='stylesheet'/>
<script src='hardtack.js'></script>
Create an input element with the class ht-input
.
<input id='tag-editor' class='ht-input' type='text' />
Initialize hardtack.
ht.setup('#tag-editor');
Call the library to add or remove tags.
ht.add('My Tag');
ht.remove('My Tag');
Initialize hardtack by calling setup()
with the editor element id.
ht.setup('#tag-editor');
By default hardtack creates tags with the class ht-label
. To add your
your own class(es):
ht.setTagClass('my-class my-other-class');
Add tag with the string My Tag
:
ht.add('My Tag');
Remove tag with the string My Tag
:
ht.remove('My Tag');
ht.removeAll();
When the user types in the tag editor and hits Return
, the tagAdded
event fires.
When the user clicks a tag to remove it, the tagRemoved
event fires.
Send bug reports and patches to craig@seagrape.us.