Topic: mdb-autocomplete event onselect
I am using the mdb.4.10.0/mdb-autocomplete.min.js component that came with pro and I have everything working up to get the value selected. I am only getting the value prior to the selection, I assume it fires before the value is written. I need help in getting the selected value. I saw older post about code to mdb.js file, but all I have is the mins and cant determine if the fix at the bottom is relevant.
JavaScript: $(document).ready(function() { $.getJSON("URL TO JSON", function(suggestions){ $('#search').mdbAutocomplete({ data: suggestions, }); });
$('#search').change(function(){
console.log(this.value);
});
});
</script>
HTML:
FIX Offered In Another POST by MDB Staff: $autocomplete.on('click', 'li', function (e) { // Set input value after click $input.val($(this).text()); $input.trigger("change");
// Clear autocomplete $autocomplete.empty(); })
Mateusz Łubianka staff answered 5 years ago
Hi @d2newlife,
In my opinion this a little issue, so I'll create the task to check this and fix. I will answer you soon with solution of this problem
Best,
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.10.0
- Device: Unknown
- Browser: Chrome Version 79.0.3945.88
- OS: Windows 10 Pro
- Provided sample code: No
- Provided link: No
d2newlife commented 5 years ago
My JavaScript / HTML were messed up on post: retrying
input class="form-control mdb-autocomplete" type="text" id="search" placeholder="stock symbol..." autocomplete="off"