I am creating a dynamic form for a hospital. Here i have a problem with data-autocomplete. The problem is after updating json array to data-autocomplete=' ' it is not updating the value of data-autocomplete=' '. AS I am using html(bootstrap) and php templete for my frontend forms so,all links are properly arrenged and one input element similar to this is working fine but i have updated the values using php for that input.
Html code
<input type='text' class="form-control ui-autocomplete-input" data-autocomplete='' autocomplete="off" id="patient_type_desc" name="patient_type_desc" class="form-control" />
JQuery Code
$.post(url, {"referral":referral}, function(data){
//console.log(data);
$('#patient_type_desc').attr('data-autocomplete', data);
});
This code is updating the value, but in form autocomplete is not populating with suggestions.
The data variable is like below
["name1","name2"]
I tried with this jQuery code also but no use - This code not at all working
$( "#patient_type_desc" ).autocomplete({
source: data
});