I am using Jquery UI autocomplete, on another dropdown selection an ajax get JSON data to load in autocomplete dropdown(#styleid), But options are not selectable in chrome. My chrome verson is 74.0.3729.131. While this code is working in firefox.
My Code is:
var items = obj.style_options ;
$( "#styleid" ).autocomplete({
minLength: 0,
source: function( request, response ) {
var string = $( "#styleid" ).val().replace(/,\s*$/, "");
var removeItem = string.split(',');
if(removeItem.length>0){
for(var k=0;k<removeItem.length;k++){
var cmpVal = $.trim(removeItem[k]);
if(cmpVal!=''){
items = jQuery.grep(items, function(value) {
return value != cmpVal;
});
}
}
//items = items.filter( function( el ) {
// return !removeItem.includes( el );
//} );
}
//console.log(items);
response( $.ui.autocomplete.filter(
items, extractLast( request.term ) ) );
},
select: function( event, ui ) {
console.log(ui.item.value);
var terms = split( this.value );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
this.value = terms.join( ", " );
///
////
return false;
},
focus: function() {
$(this).data("uiAutocomplete").search($(this).val());
}
}).focus(function(){
// The following works only once.
// $(this).trigger('keydown.autocomplete');
// As suggested by digitalPBK, works multiple times
// $(this).data("autocomplete").search($(this).val());
// As noted by Jonny in his answer, with newer versions use uiAutocomplete
$(this).data("uiAutocomplete").search($(this).val());
});;`
from Jquery UI autocomplete select event not working in chrome 74
No comments:
Post a Comment