unexpected result function autocomplete() Jquery
-
Hallo! I have a textbox , (made with Zendform), and y load the results of an array in this textbox with the autocomplete(); function , this was performing as expected a few days ago, but today the result is disgusting..the results appear by the textbox this way: .Galicia .Asturias .[...] this function its asociated with a"keyup" event...please any idea of what could be wrong??, I executed in Chrome, and the compilator, shows no errors... :omg: thanks!! ;) so let´s go to the code $(document).ready(function(){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Islas Baleares" ]; <pre> $("#comu").keyup(function(){ $(this).autocomplete({ source:comunidades }); }); </pre> <pre> <label>Comunidad</label> <?php $fComu=$formNewClienteHotel->get("comunidad"); echo $this->formInput($fComu); ?> </pre> This is the class where the Form is declared:
setAttributes(array(
'action'=>'',
'method'=>'post'
));$this->add(array( 'name'=>'comunidad', 'attributes'=>array( 'type'=>'text', 'required'=>'required', 'id'=>'comu', ) ));
-
Hallo! I have a textbox , (made with Zendform), and y load the results of an array in this textbox with the autocomplete(); function , this was performing as expected a few days ago, but today the result is disgusting..the results appear by the textbox this way: .Galicia .Asturias .[...] this function its asociated with a"keyup" event...please any idea of what could be wrong??, I executed in Chrome, and the compilator, shows no errors... :omg: thanks!! ;) so let´s go to the code $(document).ready(function(){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Islas Baleares" ]; <pre> $("#comu").keyup(function(){ $(this).autocomplete({ source:comunidades }); }); </pre> <pre> <label>Comunidad</label> <?php $fComu=$formNewClienteHotel->get("comunidad"); echo $this->formInput($fComu); ?> </pre> This is the class where the Form is declared:
setAttributes(array(
'action'=>'',
'method'=>'post'
));$this->add(array( 'name'=>'comunidad', 'attributes'=>array( 'type'=>'text', 'required'=>'required', 'id'=>'comu', ) ));
Calling
autocomplete
on every key press will most likely cause problems. You would normally only call theautocomplete
function once:$(function(){
var comunidades = [
"Galicia",
"Asturias",
"Cantabria",
"Islas Baleares"
];$("#comu").autocomplete({ source: comunidades });
});
If that doesn't work, then you'll need to tell us which autocomplete library you're using. NB:
$(document).ready(...)
is deprecated:.ready() | jQuery API Documentation[^]:
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
$( handler )
$( document ).ready( handler )
$( "document" ).ready( handler )
$( "img" ).ready( handler )
$().ready( handler )
As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Calling
autocomplete
on every key press will most likely cause problems. You would normally only call theautocomplete
function once:$(function(){
var comunidades = [
"Galicia",
"Asturias",
"Cantabria",
"Islas Baleares"
];$("#comu").autocomplete({ source: comunidades });
});
If that doesn't work, then you'll need to tell us which autocomplete library you're using. NB:
$(document).ready(...)
is deprecated:.ready() | jQuery API Documentation[^]:
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
$( handler )
$( document ).ready( handler )
$( "document" ).ready( handler )
$( "img" ).ready( handler )
$().ready( handler )
As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Hallo!! thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work.. :sigh: $(window).on("load",function(e){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Euskadi"] $("#comu").autocomplete({ source:comunidades }); }); "If that doesn't work, then you'll need to tell us which autocomplete library you're using" ?> Thank u!!! :)</x-turndown>
-
Hallo!! thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work.. :sigh: $(window).on("load",function(e){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Euskadi"] $("#comu").autocomplete({ source:comunidades }); }); "If that doesn't work, then you'll need to tell us which autocomplete library you're using" ?> Thank u!!! :)</x-turndown>
-
Hallo!! thanks a lot, for your prompt reply, so, I followed your advices, but it doesn´t work.. :sigh: $(window).on("load",function(e){ var comunidades=[ "Galicia", "Asturias", "Cantabria", "Euskadi"] $("#comu").autocomplete({ source:comunidades }); }); "If that doesn't work, then you'll need to tell us which autocomplete library you're using" ?> Thank u!!! :)</x-turndown>
$(function(){
var comunidades = [
"Galicia",
"Asturias",
"Cantabria",
"Euskadi"
];$("#comu").autocomplete({ source: comunidades });
});
Assuming you have an
<input>
withid="comu"
somewhere in your document, and you've linked to the jQuery UI CSS[^] as well as the scripts, that should work. It's virtually identical to the first example on the jQuery UI site[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
$(function(){
var comunidades = [
"Galicia",
"Asturias",
"Cantabria",
"Euskadi"
];$("#comu").autocomplete({ source: comunidades });
});
Assuming you have an
<input>
withid="comu"
somewhere in your document, and you've linked to the jQuery UI CSS[^] as well as the scripts, that should work. It's virtually identical to the first example on the jQuery UI site[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer