Skip to content

Instantly share code, notes, and snippets.

@mightyteja
Created March 10, 2020 17:42
Show Gist options
  • Save mightyteja/8e18de5e2f4f23656b2ce724558b644d to your computer and use it in GitHub Desktop.
Save mightyteja/8e18de5e2f4f23656b2ce724558b644d to your computer and use it in GitHub Desktop.
Populating database content in Materialize Autocomplete with Jquery - Laravel
<div class="row">
<div class="col s12">
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">textsms</i>
<input type="text" id="autocomplete-input" class="autocomplete">
<label for="autocomplete-input">Autocomplete</label>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
var name = {};
var technicians = {!! $technicians->toJson() !!};
for (var i = 0; i < technicians.length; i++) {
name[technicians[i].first_name] = null;
}
$('input.autocomplete').autocomplete({
data : name,
minLength: 2,
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment