Add Tags From Predefined Data - jQuery simply-tag

File Size: 7.87 KB
Views Total: 3358
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Add Tags From Predefined Data - jQuery simply-tag

A really simple tagging plugin for jQuery that allows you to add tags/tokens from an autocomplete dropdown populated with predefined JSON data.

How to use it:

1. Add jQuery JavaScript library and the jQuery simply-tag plugin's files to the web page.

<link href="simply-tag.css" rel="stylesheet">
<script src="" 
<script src="simply-tag.js"></script>

2. Create a container to place the tag input.

<div id="demo"></div>

3. Initialize the plugin and specify the predefined data as these:

  dataSource: JSON.parse('[
    { "key": 1, "value": "JQuery" }, 
    { "key": 2, "value": "Script" }, 
    { "key": 3, "value": "Net" }

4. That's it. The plugin will convert the empty container into a tag input like this:

<div class="simply-tag-root">
  <span class="simply-tags"></span>
  <input id="txt-input" dir="auto" spellcheck="true" type="text" size="1" placeholder="" autocomplete="off">
  <span class="simply-tag-loader"></span>
  <div id="test" style="display: none;"></div>
  <div class="simply-tag-suggestion-root" style="left: 0px; top: 100%; display: none; position: absolute; z-index: 1000;"></div>
  <span style="display:none" class="simply-tag-current" data-type="valid"></span>

5. All default configuration options.

  allowSpecialChar: false,
  isLocal: true, // or remote data source via ajax
  dataSource: null,
  key: 'key',
  value: 'value',

6. Add a tag manually.

var jsonData = $('#test').simplyTag('additem',JSON.parse('{ "key": 0, "value": "Direct Add" }'));

This awesome jQuery plugin is developed by SinghChandrabhan. For more Advanced Usages, please check the demo page or visit the official website.