-
Notifications
You must be signed in to change notification settings - Fork 48
/
example.html
177 lines (152 loc) · 3.98 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue Autocomplete Component</title>
<link rel="stylesheet" href="./vue-autocomplete.css">
<style>
.main{
margin-left: 35px;
display: inline-block;
float: left;
width: 25%;
margin-right: 235px;
}
.preview{
display: inline-block;
float: left;
max-width: 45%;
}
pre{
background: #f8f8f8;
padding: 15px;
}
</style>
</head>
<body>
<div class="main">
<h1>Vue Autocomplete {{ vModelLike }}</h1>
<autocomplete
id="input__id-optional"
class="input_class optional"
name="people"
placeholder="Type Here"
url="http://localhost:3000/remote-list/klien"
param="q"
limit="5"
anchor="value"
label="label"
model="vModelLike">
</autocomplete>
</div>
<div class="preview">
<h1>Data Selected</h1>
<pre>{{ data | json 2 }}</pre>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.14/vue.min.js"></script>
<!-- <script src="./vue-autocomplete.js"></script> -->
<script src="./vue-autocomplete.min.js"></script>
<script>
new Vue({
el: 'body',
data: function() {
return {
vModelLike: "",
data: {}
};
},
events: {
/**
* Global Autocomplete Callback Event
*
* @event-name autocomplete:{event-name}
* @param {String} name name of auto
* @param {Object} data
* @param {Object} json - ajax-loaded only
*/
// Autocomplete on before ajax progress
'autocomplete:before-ajax': function (name,data){
console.log('before-ajax',name,data);
},
// Autocomplete on ajax progress
'autocomplete:ajax-progress': function(name,data){
console.log('ajax-progress',data);
},
// Autocomplete on ajax loaded
'autocomplete:ajax-loaded': function(name,data,json){
console.log('ajax-loaded',data,json);
},
// Autocomplete on focus
'autocomplete:focus': function(name,evt){
console.log('focus',name,evt);
},
// Autocomplete on input
'autocomplete:input': function(name,data){
console.log('input',data);
},
// Autocomplete on blur
'autocomplete:blur': function(name,evt){
console.log('blur',evt);
},
// Autocomplete on show
'autocomplete:show': function(name){
console.log('show',name);
},
// Autocomplete on selected
'autocomplete:selected': function(name,data){
console.log('selected',data);
this.data = data;
},
// Autocomplete on hide
'autocomplete:hide': function(name){
console.log('hide',name);
},
/**
* Spesific Autocomplete Callback Event By Name
*
* @event-name autocomplete-{component-name}:{event-name}
* @param {String} name name of auto
* @param {Object} data
* @param {Object} json - ajax-loaded only
*/
// Autocomplete on before ajax progress
'autocomplete-people:before-ajax': function(data){
console.log('before-ajax-people',data);
},
// Autocomplete on ajax progress
'autocomplete-people:ajax-progress': function(data){
console.log('ajax-progress-people',data);
},
// Autocomplete on ajax loaded
'autocomplete-people:ajax-loaded': function(data,json){
console.log('ajax-loaded-people',data,json);
},
// Autocomplete-people on focus
'autocomplete-people:focus': function(evt){
console.log('focus-people',evt);
},
// Autocomplete-people on input
'autocomplete-people:input': function(data){
console.log('input-people',data);
},
// Autocomplete-people on blur
'autocomplete-people:blur': function(evt){
console.log('blur-people',evt);
},
// Autocomplete-people on show
'autocomplete-people:show': function(){
console.log('show-people');
},
// Autocomplete-people on selected
'autocomplete-people:selected': function(data){
console.log('selected-people',data);
},
// Autocomplete-people on hide
'autocomplete-people:hide': function(){
console.log('hide-people');
},
}
});
</script>
</body>
</html>