Topic: Not able to load data for md-autocomplete at the time of keyup
pavan_kp free asked 4 years ago
Here is my code:
HTML:
< input type="search" name="SearchLoadID" id="SearchLoadID" class="form-control mdb-autocomplete" ng-model="SearchLoadID" ng-click="getLoads($event,SearchLoadID)" />
< button class="mdb-autocomplete-clear">
< 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" />
< label for="SearchLoadID">Load ID
app.js
$scope.getLoads = function(event,viewValue ) {
if(viewValue != '') {
var options = function() {
var loads = [];
$.ajax({
method: 'POST',
url: host+'receive/includes/receive_submit.php?ajax=GetLoads&keyword='+viewValue,
dataType: 'json',
async: false,
global: false,
success: function(data) {
for(var key in data['Result']){
if( !data['Result'].hasOwnProperty(key) || !data['Result'].hasOwnProperty("LoadId")) {
loads.push(data['Result'][key]["LoadId"]);
}
}
}
});
return loads;
}();
$('.mdb-autocomplete-wrap').remove();
$('input#SearchLoadID').mdbAutocomplete({
data: options
});
}
};
Getting the value from ajax call as below:
{ 0: "ACEE5644246" 1: "ACEE8016750" 2: "ACEE6694857" 3: "ACEE3062474" 4: "ACEE4278379" 5: "ACEE3958569" 6: "ACEE0773894" 7: "ACEE8740829" 8: "ACEE5926527" 9: "ACEE5757205" 10: "ACEE0970321" 11: "ACEE6640468" 12: "ACEE7483175" 13: "ACEE0814270" 14: "ACEE4474086" 15: "ACEE621977" 16: "ACEE0291439" 17: "ACEE2307658" 18: "ACEE1661695" }
But data is not still binding. Please help me out
Mateusz Łubianka staff answered 4 years ago
Hi,
please, create a snippet showing your problem here: https://mdbootstrap.com/snippets/. I'll try to help you.
Best,
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.12.0
- Device: Monitor
- Browser: Chrome
- OS: OS
- Provided sample code: No
- Provided link: No