im using jquery ui to achieve autocomplete. mY code looks like this
$(function(){
$('input[name=store]').attr('autocomplete','on');
$( "input[name=store]" ).autocomplete({
source: function( request, response ) {
//alert('hello');
$.ajax({
url: "http://localhost/dheeps/admin/calls/callback.php",
dataType: "jsonp",
data: {
sub:"searchstore",
store: request.term
},
success: function( data ) {
//alert('hello');
response( $.map( data.data, function( item ) {
//alert(item);
return {
label: item.name + (item.id1 ? ", " + item.adminName1 : "") + ", " + item.id,
value: item.id
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
//alert('helo');
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
});
And the in the html of the form I found the input's element autocomplete attribute set to off. Is this why my code is not working. Please guide me
PUT BELOW
$('input[name=store]').attr('autocomplete','on');
AFTER THIS
$( "input[name=store]" ).autocomplete({});
Because autocomplete
attribute will added to element after initialization.
Thanks for this info. This solved the problem. I think this is very odd that a simple test example works with no problem. Then, when I put it into a big project, it gets disabled automatically.
$(function () {
var availableTags = ["One", "Two", "Three"];
$("#myinput").autocomplete({
source: availableTags
});
$("#myinput").attr('autocomplete', 'on');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With