This example is build on top of the HTML5 datalist element and uses webshims to polyfill and enhance the user interface.
72 | 73 | 74 |
97 | <input data-remote-list="data.json"
98 | data-list-highlight="true"
99 | data-list-value-completion="true"
100 | class="static-remote" type="text" />
101 |
102 |
103 |
104 | $('input.static-remote').remoteList({
105 | minLength: 0,
106 | maxLength: 0,
107 | select: function(){
108 | if(window.console){
109 | console.log($(this).remoteList('selectedOption'), $(this).remoteList('selectedData'))
110 | }
111 | }
112 | });
113 |
114 |
156 | <input
157 | data-list-filter="!"
158 | class="geo-autocomplete" type="text" />
159 |
160 |
161 |
162 | $('input.geo-autocomplete').remoteList({
163 | maxLength: 9,
164 | source: function(val, response){
165 | $.ajax({
166 | url: 'http://geo-autocomplete.com/api/country',
167 | dataType: 'jsonp',
168 | data: {
169 | q: val,
170 | key: '37693c',
171 | nl: true
172 | },
173 | success: function(data){
174 | $.each(data, function(i, item){
175 | item.value = item.country_name;
176 | });
177 | response(data);
178 | }
179 | });
180 | },
181 | select: function(){
182 | if(window.console){
183 | console.log($(this).remoteList('selectedOption'), $(this).remoteList('selectedData'))
184 | }
185 | }
186 | });
187 |
188 |