Selectize working.
This commit is contained in:
parent
b5f1190c13
commit
54029c2941
3 changed files with 214 additions and 165 deletions
28
resources/js/selectize-one.js
Normal file
28
resources/js/selectize-one.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* selectize one select widget. Substitute the actual id of the widget for `{{widget_id}}`.
|
||||
*/
|
||||
$('#{{widget_id}}').selectize({
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
|
||||
load: function(query, callback) {
|
||||
console.log('Desperately seeking ' + query);
|
||||
if (query === null || !query.length) return callback();
|
||||
$.ajax({
|
||||
url: '/json/auto/search-strings-electors?name=' + query,
|
||||
type: 'GET',
|
||||
dataType: 'jsonp',
|
||||
error: function() {
|
||||
console.log( 'Query ' + query + ' failed.');
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
console.log('Received ' + res + ' records for ' + query);
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue