Skip to content

Instantly share code, notes, and snippets.

View merovingienne's full-sized avatar

Chanuka Wijayakoon merovingienne

View GitHub Profile
@merovingienne
merovingienne / demo_autocomplete.js
Last active February 23, 2017 17:46
Materialize CSS Autocomplete with AJAX demo using GSMArena
function ajaxAutoComplete(options){
var $input = $("#" + options.inputId);
var $autocomplete = $('<ul id="ac" class="autocomplete-content dropdown-content" style="position:absolute"></ul>'),
$inputDiv = $input.closest('.input-field'),
request,
runningRequest = false,
timeout,
liSelected;
@merovingienne
merovingienne / autocomplete.js
Last active February 24, 2018 17:04
Materialize Autocomplete with AJAX
/*
* @function ajaxAutocomplete
* Creates an autocomplete dropdown
* from content fetched via AJAX calls.
*
* @param {Object} options
* Used to pass options to the function
* options.ajaxURL = URL for the AJAX call
* options.inputId = Input field to use for autcompletion
* options.minLength = Minimum char length to start making AJAX calls.