1
- jQuery Tags Input Plugin 1.3.2
2
-
3
- Copyright (c) 2011 XOXCO, Inc
4
-
5
- Documentation for this plugin lives here:
6
- http://xoxco.com/clickable/jquery-tags-input
7
-
8
- Licensed under the MIT license:
9
- http://www.opensource.org/licenses/mit-license.php
10
-
11
- The git repository for this plugin can be found at:
12
- https://github.com/xoxco/jQuery-Tags-Input
13
-
14
- ben@xoxco.com
15
- ------------------------------------------------------
1
+ # jQuery Tags Input Plugin
16
2
17
3
Do you use tags to organize content on your site?
18
4
This plugin will turn your boring tag list into a
@@ -22,56 +8,61 @@ all the data - your form just sees a comma-delimited
22
8
list of tags!
23
9
24
10
25
- Instructions
11
+ [ Get it from Github] ( https://github.com/xoxco/jQuery-Tags-Input )
12
+
13
+ [ View Demo] ( http://xoxco.com/projects/code/tagsinput )
14
+
15
+
16
+ ## Instructions
26
17
27
18
First, add the Javascript and CSS files to your <head > tag:
28
19
29
- <script src="jquery.tagsinput.js"></script>
30
- <link rel="stylesheet" type="text/css" href="jquery.tagsinput.css" />
20
+ <script src="jquery.tagsinput.js"></script>
21
+ <link rel="stylesheet" type="text/css" href="jquery.tagsinput.css" />
31
22
32
23
Create a real input in your form that will contain a comma-separated list of
33
24
tags. You can put any default or existing tags in the value attribute, and
34
25
they'll be handled properly.
35
26
36
- <input name="tags" id="tags" value="foo,bar,baz" />
27
+ <input name="tags" id="tags" value="foo,bar,baz" />
37
28
38
29
Then, simply call the tagsInput function on any field that should be treated as
39
30
a list of tags.
40
31
41
- $('#tags').tagsInput();
32
+ $('#tags').tagsInput();
42
33
43
34
If you want to use jQuery.autocomplete, you can pass in a parameter with the
44
35
autocomplete url.
45
36
46
- $('#tags').tagsInput({
47
- autocomplete_url:'http://myserver.com/api/autocomplete'
48
- });
37
+ $('#tags').tagsInput({
38
+ autocomplete_url:'http://myserver.com/api/autocomplete'
39
+ });
49
40
50
41
If you're using the bassistance jQuery.autocomplete, which takes extra
51
42
parameters, you can also send in options to the autocomplete plugin, as
52
43
described here.
53
44
54
- $('#tags').tagsInput({
55
- autocomplete_url:'http://myserver.com/api/autocomplete',
56
- autocomplete:{selectFirst:true,width:'100px',autoFill:true}
57
- });
45
+ $('#tags').tagsInput({
46
+ autocomplete_url:'http://myserver.com/api/autocomplete',
47
+ autocomplete:{selectFirst:true,width:'100px',autoFill:true}
48
+ });
58
49
59
50
You can add and remove tags by calling the addTag() and removeTag() functions.
60
51
61
- $('#tags').addTag('foo');
62
- $('#tags').removeTag('bar');
52
+ $('#tags').addTag('foo');
53
+ $('#tags').removeTag('bar');
63
54
64
55
You can import a list of tags using the importTags() function...
65
56
66
- $('#tags').importTags('foo,bar,baz');
57
+ $('#tags').importTags('foo,bar,baz');
67
58
68
59
You can also use importTags() to reset the tag list...
69
60
70
- $('#tags').importTags('');
61
+ $('#tags').importTags('');
71
62
72
63
And you can check if a tag exists using tagExist()...
73
64
74
- if ($('#tags').tagExist('foo')) { ... }
65
+ if ($('#tags').tagExist('foo')) { ... }
75
66
76
67
If additional functionality is required when a tag is added or removed, you may
77
68
specify callback functions via the onAddTag and onRemoveTag parameters. Both
@@ -91,19 +82,18 @@ option to false.
91
82
92
83
Options
93
84
94
- $(selector).tagsInput({
95
- 'autocomplete_url': url_to_autocomplete_api,
96
- 'autocomplete': { option: value, option: value},
97
- 'height':'100px',
98
- 'width':'300px',
99
- 'interactive':true,
100
- 'defaultText':'add a tag',
101
- 'onAddTag':callback_function,
102
- 'onRemoveTag':callback_function,
103
- 'onChange' : callback_function,
104
- 'removeWithBackspace' : true,
105
- 'minChars' : 0,
106
- 'maxChars' : 0 //if not provided there is no limit,
107
- 'placeholderColor' : '#666666'
108
- });
109
-
85
+ $(selector).tagsInput({
86
+ 'autocomplete_url': url_to_autocomplete_api,
87
+ 'autocomplete': { option: value, option: value},
88
+ 'height':'100px',
89
+ 'width':'300px',
90
+ 'interactive':true,
91
+ 'defaultText':'add a tag',
92
+ 'onAddTag':callback_function,
93
+ 'onRemoveTag':callback_function,
94
+ 'onChange' : callback_function,
95
+ 'removeWithBackspace' : true,
96
+ 'minChars' : 0,
97
+ 'maxChars' : 0 //if not provided there is no limit,
98
+ 'placeholderColor' : '#666666'
99
+ });
0 commit comments