Topic: Autocomplete not working (mdb_autocomplete is not a function)
Jake Benyon
pro asked 10 years ago
TypeError: $(...).mdb_autocomplete is not a function
The code I'm using is:
<div class="md-form">
<input type="search" id="form-autocomplete" class="form-control mdb-autocomplete">
<button class="mdb-autocomplete-clear">
<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
<path d="M0 0h24v24H0z" fill="none" />
</svg>
</button>
<label for="form-autocomplete" class="active">What is your favorite US state?</label>
</div>
<script type="text/javascript">
var states = [
"Alabana",
"Alaska",
"Arizona",
"Arkansas",
"California",
];
$('.mdb-autocomplete').mdb_autocomplete({
data: states
});
</script>
Searching through the JS file, there is no reference to mdb_autocomplete at all. Any help would be much appreciated.
Magdalena Obalska
answered 10 years ago
Jake Benyon
pro answered 10 years ago
Magdalena Obalska
answered 10 years ago
TEY
pro answered 9 years ago
Jake Benyon pro commented 9 years ago
You're trying to use the function before the script has been loaded - try putting: $(‘.mdb-autocomplete’).mdb_autocomplete({ data: states }); into a $(document).ready() function.Magdalena Obalska commented 9 years ago
Thanks for your answer, Jake. TEY, try to use Jake's solution.FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No