javascript - jquery autocomplete accept without selecting from dropdown -
im using autocomplete plugin show user options choose when typing word.
the problem here is:
this code won't allow word if user types correctly word match avaible tags without clicking on showed items on dropdown.
how can fix it?, have.
$( "#fuente" ).autocomplete({ source: availabletags, change: function (event, ui) { if (ui.item == null || ui.item == undefined) { $("#fuente").val(""); $("#fuente").attr("disabled", false); $('#fuente').removeclass('fuenteboxcheck'); $('#fuente').addclass('fuenteboxncheck'); } else { $('#fuente').removeclass('fuenteboxncheck'); $('#fuente').addclass('fuenteboxcheck'); } } });
is there easy way fix this?, pls halp. thnx.
ok.. did more research , found solution problem. hope helps else problem.
var lastvalue; var lastvalue; $("#fuente").autocomplete({ source: availabletags, select: function(event, ui) { lastvalue = ui.item.value; }, response: function(event, ui) { //lastvalue = ui.content.length > 0 ? ui.content[0].value : ''; if(ui.content.length > 0){ lastvalue = ui.content[0].value; $('#fuente').removeclass('fuenteboxncheck'); $('#fuente').addclass('fuenteboxcheck'); } else{ lastvalue = ''; $('#fuente').removeclass('fuenteboxcheck'); $('#fuente').addclass('fuenteboxncheck'); } } }); $("#fuente").on('blur', function() { $(this).val(lastvalue); });lse{ lastvalue = ''; $('#fuente').removeclass('fuenteboxcheck'); $('#fuente').addclass('fuenteboxncheck'); } } }); $("#fuente").on('blur', function() { $(this).val(lastvalue); }); });
thnx.
Comments
Post a Comment