Autocomplete label not displaying data on hidden input field with display:none Attribute after showing.
I am trying to autocomplete data from MySQL database with the below-given script. It is not displaying label while it is giving correct response in developer tool network console. When I show the div with the .show() method, the autocomplete not displaying label .
function openSearchDiv(){
$('.search').show();
}
$(document).on('focus','#search',function(){
$(this).autocomplete({
source: function( request, response ) {
$.ajax({
url: 'products.php',
dataType: 'json',
method: 'post',
data: {
name_startsWith: request.term,
type: 'type'
},
success: function( data ) {
response( $.map( data, function( item ) {
return {
label: item['id'],
value: item['id'],
data : item
}
}));
}
});
},
autoFocus: true,
minLength: 1,
select: function( event, ui ) {
// $('#player').val(ui.item.data.player);
// $('#marks').val(ui.item.data.marks);
}
});
});
.search {
display:none;
margin-top: 20px;
}
<div class="search">
<input type="text" id="search" placeholder="Type Id" />
</div>
I have checked this code out of display:none attribute it's working perfectly
from Autocomplete label not displaying data on hidden Element
No comments:
Post a Comment