forked from vorotina/vanilla-select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
87 lines (75 loc) · 1.85 KB
/
example.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
<html lang="en">
<head>
<meta charset="UTF-8">
<title>VanillaSelect - standalone replacement for select elements</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:400,300">
<link rel="stylesheet" type="text/css" href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="dist/vanilla-select.css">
<style>
*{padding:0; margin:0;}
body {
font: 300 15px Roboto, Calibri;
}
.content {
margin: 50px auto 0;
width: 300px;
}
h2 {
margin-bottom:10px;
}
h3 {
padding-top: 25px;
font-weight: normal;
}
.select-box {
font-family: Roboto, Arial;
margin: 25px 0;
}
</style>
</head>
<body>
<div class="content">
<h2>EXAMPLE:</h2>
<h3>Support search:</h3>
<div ref="select" class="select-box"></div>
<div ref="select" class="select-box"></div>
<h3>And default selected option:</h3>
<div ref="select2" class="select-box"></div>
</div>
<script src="dist/vanilla-select.min.js"></script>
<script>
const source = [{
icon: 'fa fa-font',
value: 'Abril Fatface'
},
{
icon: 'fa fa-font',
value: 'Allura'
},
{
icon: 'fa fa-font',
value: 'Amatic SC'
}
];
let select = Array.from(document.querySelectorAll('[ref="select"]')).map(el => {
return new Select({
placeholder: 'Select Font',
search: true,
noResults: 'No results found',
dataset: source,
onSelected: item => console.log(item)
}).componentMount({
el: el
});
});
let select2 = new Select({
dataset: source,
selected: source[1].value,
onSelected: item => console.log(item)
}).componentMount({
el: document.querySelector('[ref="select2"]')
});
</script>
</body>
</html>