Search and Top Navigation
#7473 closed bug (notabug)
Opened June 14, 2011 01:08PM UTC
Closed June 14, 2011 01:09PM UTC
Last modified June 14, 2011 01:24PM UTC
With some char the autocomplete doesn't work fine.
Reported by: | rinosan_76 | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.autocomplete | Version: | 1.8.13 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Sorry for my bad english but I'm italian. I realize that autocomplete doesn't work with some char but I don't know why. Perhaps i'm wrong something... so i post my code HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Prova form in php</title> <link rel="stylesheet" type="text/css" href="../librerie_ext/jquery/css/jquery-ui-1.8.9.custom.css" media="all" /> <script src="../librerie_ext/jquery/js/jquery.min.js" type="text/javascript"></script> <script src="../librerie_ext/jquery/js/jquery-ui-custom.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(".H_nazione").autocomplete({ source: "cerca_stati.php", select: function(event, ui) { $(".H_provincia").val(""); $(".H_citta").val(""); $(".H_cap").val(""); }, }).data("autocomplete")._renderItem=function(ul,item){ return $( "<li></li>" ).data( "item.autocomplete", item ).append('<a><span class="gras">'+item.label.substr(0,item.ini.length)+'</span>'+item.label.substr(item.ini.length) + '</a>').appendTo( ul ); } }); </script> </head> <body> <form name="modulo" method="post" class="acapo" action="prova_form2.php?AGG=1&PHPSESSID=g7u3hr802cabq7ca5ghnuutgf3"> <label for="stato" id="lab_stato">Stato<span class="required">*</span></label> <input type="text" tabindex="100" id="stato" name="stato" class="input H_nazione" value="Italia" /> </form> </body> </html>
and my PHP (cerca_stati.php):
<?PHP $q=false; $a=""; if(isset($_GET["term"])) $q = strtolower($_GET["term"]); if (!$q) return; $items=array("Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antartica","Antigua e Barbuda","Antille Olandesi","Arabia Saudita","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgio","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia e Erzegovina","Botswana","Brasile","Brunei","Bulgaria","Burkina Faso","Burundi","Cambogia","Camerun","Canada","Capo Verde","Ciad","Cile","Cina","Cipro","Città del Vaticano (Santa Sede)","Columbia ","Comoros","Congo","Corea","Corea D.P.R. ","Costa Rica","Cote D'Ivoire (Costa d'Avorio)","Croazia (Hrvatska)","Cuba","Danimarca","Dominica","East Timor","Ecuador","Egitto","El Salvador","Emirati Arabi Uniti","Eritrea","Estonia","Etiopia","Figi","Filippine","Finlandia","Francia","Gabon","Gambia","Georgia","Georgia del Sud","Germania","Ghana","Giamaica","Giappone","Gibilterra","Gibuti","Giordania","Grecia","Grenada","Groenlandia","Guadalupe","Guam","Guatemala","Guinea","Guinea Equatoriale","Guinea-Bissau","Guyana","Guyana Francese","Haiti","Honduras","Hong Kong SAR - PRC","India","Indonesia","Iran","Iraq","Irlanda","Islanda","Isola Bouvet","Isola Riunione","Isole Cayman ","Isole Cocos (Keeling)","Isole Cook ","Isole Falkland (Malvine)","Isole Faroe ","Isole Heard e McDonald ","Isole Mariana Settentrionali","Isole Marshall ","Isole Maurizio","Isole Natale","Isole Norfolk ","Isole Outlying Minori USA","Isole Salomone","Isole Samoa USA","Isole Turks e Caicos ","Isole Vergini (Britanniche)","Isole Vergini (US)","Isole Wallis e Futuna ","Israele","Italia","Jugoslavia","Kazakhstan","Kenya","Kiribati","Kuwait","Kyrgyzstan","Lao","Lesotho","Lettonia","Libano","Liberia","Libia","Liechtenstein","Lituania","Lussemburgo","Macao","Macedonia","Madagascar","Malawi","Maldive","Malesia","Mali","Malta","Marocco","Martinique","Mauritania","Mayotte","Messico","Micronesia","Moldavia","Monaco","Mongolia","Montserrat","Mozambico","Myanmar","Namibia","Nauru","Nepal","Nicaragua","Niger","Nigeria","Niue","Norvegia","Nuova Caledonia","Nuova Zelanda","Oman","Paesi Bassi","Pakistan","Palau","Panama","Papua Nuova Guinea","Paraguay","Perù","Pitcairn","Polinesia Francese","Polonia","Porto Rico","Portogallo","Qatar","Regione di Taiwan","Regno Unito","Repubblica Democratica del Congo (Zaire)","Repubblica Ceca","Repubblica Centroafricana","Repubblica Domenicana","Repubblica Slovacca","Romania","Ruanda","Russia","Sahara Occidentale","Samoa","San Kitts e Nevis","San Marino","San Tome e Principe","San Vincent e le Grenadine","Santa Lucia","Sant'Elena","Senegal","Seychelles","Sierra Leone","Singapore","Siria","Slovenia","Somalia","Spagna","Sri Lanka","St Pierre e Miquelon","Stati Uniti","Sud Africa","Sudan","Suriname","Svalbard e Isole Jan Mayen ","Svezia","Svizzera","Swaziland","Tailandia","Tajikistan","Tanzania","Territori Britannici dell'Oceano Indiano","Territori Francesi del Sud","Togo","Tokelau","Tonga","Trinidad e Tobago","Tunisia","Turchia","Turkmenistan","Tuvalu","Ucraina","Uganda","Ungheria","Uruguay","Uzbekistan","Vanuatu","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe"); $result = array(); asort($items); foreach ($items as $item) { $n=strlen($q); if (substr(strtolower($item), 0,$n) == strtolower($q)) { array_push($result, array("ini"=>$q, "label"=>$item, "value" => strip_tags($item))); } } echo array_to_json($result); //########################################################################################################################## function array_to_json( $array ){ if( !is_array( $array ) ){ return false; } $associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) )); if( $associative ){ $construct = array(); foreach( $array as $key => $value ){ if( is_numeric($key) ){ $key = "key_$key"; } $key = "\\"".addslashes($key)."\\""; if( is_array( $value )){ $value = array_to_json( $value ); } else if( !is_numeric( $value ) || is_string( $value ) ){ $value = "\\"".addslashes($value)."\\""; } $construct[] = "$key: $value"; } $result = "{ " . implode( ", ", $construct ) . " }"; }else{ $construct = array(); foreach( $array as $value ){ if( is_array( $value )){ $value = array_to_json( $value ); } else if( !is_numeric( $value ) || is_string( $value ) ){ $value = "'".addslashes($value)."'"; } $construct[] = $value; } $result = "[" . implode( ",", $construct ) . "]"; } return $result; } ?>
If i type "a" it works fine but if i type "s" doesn't works. Why?
Attachments (0)
Change History (4)
Changed June 14, 2011 01:09PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed June 14, 2011 01:09PM UTC by comment:2
component: | ui.core → ui.autocomplete |
---|
Changed June 14, 2011 01:14PM UTC by comment:3
It isn't a bug?
Changed June 14, 2011 01:24PM UTC by comment:4
No, there's no bug in autocomplete with remote resources. Check any of our demos, they all work fine.
Please use the forums for help.