You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+133-8Lines changed: 133 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,13 @@
1
1
# Bootstrap Tags
2
2
3
-
In fact it is not tags it sort of mix of typeahead, and pills. I just did not know how to name it in english, I named it after my task I did it to use in my applicatin to manage tags.
3
+
In fact it is not tags it sort of mix of typeahead, and tags/pills. I just did not know how to name it in english, I named it after my task I did it to use in my application to manage tags.
4
4
5
+
Please see [demo](http://bootstrap-tags.azurewebsites.net/) here. Demo is updated automatically on every push to repository so it always contains latest version.
6
+
7
+
## Features
8
+
9
+
- Based on templates. Thus you can change any HTML markup of any element, and fully control how this UI components looks.
10
+
- Flexible API. There are few methods to make the same thing like pre-populate, remove or add tags/pills. you can use it as standard element with form submission or on fully AJAXed sites.
5
11
6
12
## Install
7
13
@@ -36,15 +42,112 @@ to see what files to use run
36
42
37
43
The minimal requirments are Bootstrap and jquery loaded and `bootstrap-tags.css`, `bootstrap-tags.js`.
38
44
39
-
## Load deafult values
45
+
## Feed format
46
+
47
+
As for default values or _typeahead_ suggestions the format is the same. It is an array of values. Values can be `string` or `object` or mixed.
48
+
49
+
[
50
+
{
51
+
"id": "1",
52
+
"text": "Apple",
53
+
"html": "This is <b>Apple</b>!",
54
+
"num": 5
55
+
},
56
+
{
57
+
"id": "3",
58
+
"text": "Mango",
59
+
"html": "I like <b>Mango</b>!",
60
+
"url": "/"
61
+
},
62
+
"Banana"
63
+
]
64
+
65
+
Object may contain following properties
66
+
67
+
Property | Required | Description
68
+
---------|----------|------------
69
+
id | Yes | Required only if object. If it is a string, the same value for `text` and `id` will be used.
70
+
text | Yes | Used as tag text.
71
+
html | No | If not set `text` will be used. This property is used to display in typeahead suggestions.
72
+
num | No | If set, number will be shown after the text.
73
+
url | No | If set, text will be as link. Not that there is `tag_link_target` option. Eg. `$('#bs-tags').tags({tag_link_target:"_blank"});`
74
+
75
+
## Options
76
+
77
+
You can use following options when construction element. Like `$('#bs-tags').tags(options);`
78
+
79
+
Option | Default | Description
80
+
-------|---------|------------
81
+
values | [] | Default values to pre-populate component with tags/pills
82
+
tag\_link\_target || Default target for tags/pills with links. To add link to tag you have to set `url` property in feed object. See _Feed format_ for details.
83
+
can_delete | true | Set if current user can delete tags/pills
84
+
can_add | true | Set if current users can add new tags
85
+
remove_url | | Set URL where `POST` request will be sent on tag/pill removal.
86
+
input_name | tags[] | Set name of the hidden `<input>` element to be added with every tag/pill. Ше should end with `[]` in order to support multiple values.
87
+
templates | | Set HTML markup. This let you fully manage and style output as you want. No limitations. See _Templates_ for more details.
88
+
89
+
## Templates
90
+
91
+
Templates option allow you fully manage how tags/pills will look like. Then with additions of few CSS styles you may create very beautiful outputs. See demo for examples.
pill | `<span class="badge badge-info" data-tag-id="{1}">{0}</span>` | This is main HTML element of the pill. This is also what will be passed to `onRemove(pill)` method. After full pill creation it will include also hidden `<input>`, number if passed and remove icon. `{0}` is the tag text, `{1}` is the tag id. `data-tag-id` is required attribute.
108
+
number | `<sup><small>{0}</small></sup>` | If `num` property exists in _feed_ then number will be added. This is template how to format it.
109
+
delete_icon | `<i class="icon-remove-sign"></i>` | This is delete icon. If you use FontAwesome or IcoMoon you can change it to display better icon.
0 commit comments