-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (64 loc) · 2.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<title>jquery-categorypicker</title>
<script src="./vendor/jquery.min.js"></script>
<script src="./src/jquery-categorypicker.js"></script>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<div class="container">
<div class="menu">
<span><a href="./index.html" class="active">Vanilla.js</a></span>
<span><a href="./index-ko.html">Knockout.js</a></span>
</div>
<div id="categorypicker"></div>
<div class="quick">
<a id="all" href="#">All</a>
<a id="none" href="#">None</a>
</div>
<div id="categories" class="categoryselection"></div>
</div>
<script type="text/javascript">
$(function () {
var available = [
{id: "1", value: "Fruit", display: "Fruitz"},
{id: "2", value: "Vegetables", display: "Veggies"},
{id: "3", value: "Dairy", display: "Milk and stuff"},
{id: "4", value: "Meat", display: "Here piggy, piggy!"}
]
var selected = [
{id: "1", value: "Fruit"},
{id: "2", value: "Vegetables"}
]
function bindCategoryPicker() {
$("#categorypicker").categorypicker({
displayField: 'display',
availableCategories: available,
selectedCategories: selected,
onUpdate: function (selection) {
var el = $('#categories');
var list_node = $('<ul></ul>');
$.each(selection, function (i, value) {
var item_node = $('<li></li>');
item_node.html(value['value']);
list_node.append(item_node);
});
el.html(list_node);
}
})
}
$("#all").on('click', function (e) {
selected = available;
bindCategoryPicker();
e.preventDefault();
});
$('#none').on('click', function (e) {
selected = [];
bindCategoryPicker();
e.preventDefault();
});
bindCategoryPicker();
});
</script>
</body>