-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-template4.html
116 lines (109 loc) · 4 KB
/
bootstrap-template4.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bootstrap Nice Select Example in Bootstrap 4</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<link rel="stylesheet" href="./node_modules/bootstrap-nice-select/dist/css/bootstrap-nice-select.css" />
<style>
select {
width: 300px;
}
</style>
</head>
<body class="w-100">
<h1 class="text-center my-4">Examples - Bootstrap Nice Select</h1>
<div class="d-flex flex-row justify-content-around my-5">
<label class="text-center">Test with no OptGroup:</label>
<select id="exampleSelect1" data-bs-toggle="bootstrap-nice-select" multiple>
<option value="Banana">Banana</option>
<option value="Apple">Apple</option>
<option value="Orange">Orange</option>
<option value="Lemon" selected="selected">Lemon</option>
<option value="Pepper">Pepper</option>
<option value="Mushrooms">Mushrooms</option>
<option value="Cabbages">Cabbages</option>
<option value="Celery">Celery</option>
<option value="Garlic">Garlic</option>
<option value="Brocoli">Brocoli</option>
</select>
</div>
<div class="d-flex flex-row justify-content-around my-5">
<label class="text-center">Test with OptGroup:</label>
<div class="col-3">
<select id="exampleSelect2" multiple data-token-separators='[",","Enter"]' data-minimum-input-length="3">
<optgroup label="Fruit">
<option value="Banana" selected disabled>Banana</option>
</optgroup>
</select>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+"
crossorigin="anonymous"></script>
<script src="./node_modules/bootstrap-nice-select/dist/js/bootstrap-nice-select-locale-all.js"></script>
<script>
let remoteSearchData = {
items: [
{
id: "Banana",
text: "Banana",
optGroup: "Fruit",
disabled: false
},
{
id: "Apple",
text: "Apple",
optGroup: "Fruit",
disabled: false
},
{
id: "Orange",
text: "Orange",
optGroup: "Fruit",
disabled: false
},
{
id: "Pepper",
text: "Pepper",
optGroup: "Vegetable",
disabled: true
},
{
id: "Garlic",
text: "Garlic",
optGroup: "Vegetable"
}
]
}
function callRemoteData(filter) {
filter = filter.toUpperCase();
// put AJAX or Fetch for Remote JSON object here
let toRet = structuredClone(remoteSearchData);
toRet.items = toRet.items.filter(data => data.text.toUpperCase().indexOf(filter) > -1);
return toRet;
}
async function checkTag(key) {
if (key.toLowerCase().includes("ä") || key.toLowerCase().includes("ö") || key.toLowerCase().includes("ü")) {
return false;
}
return true;
}
let select = bootstrapNiceSelect.BootstrapNiceSelect("#exampleSelect2", {
searchData: 'callRemoteData',
tagsCheck: 'checkTag',
tags: true
});
</script>
</body>
</html>