I implemented autocomplete using jQuery, when I select the data, it is saved in the result table, after choosing I need to clear the autocomplete text box that I canβt. I looked for the same thing and got this Clear text box in JQuery Autocomplete after selecting , but I did not know where to put it, or in firebug, I got an error when working (event, UI). Help Pls ... my code is as follows.
$(function() { function log( message ) { $( "<div>" ).text( message ).prependTo( "#log" ).click(function(o){ $(this).remove(); }); $( "#log" ).scrollTop( 0 ); } $( "#poolName" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "/DataWeb/getPoolName", type : 'post', dataType: 'json', data: { name_startsWith: request.term }, success: function( data ) { console.log(data); response( $.map( data, function( item ) { return { label: item.poolName, value: item.poolName } })); } }); }, minLength: 1, select: function( event, ui ) { log( ui.item ? ui.item.label : "Nothing selected, input was " + this.value); }, open: function() { $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); });
source share