autocomplete - Twitter Bootstrap Typeahead only populating letter "a" -
so i'm trying populate list of countries using bootstrap typeahead. want person start typing in text field country live in , show options choose from.
initially, had data-source set variable huge array of countries strings. getting 1 singular "a" show when type in "a" itself. literally letter a.
then changed source directly hold array , array held inside of 2 single quotes. when hit key comes results, literally when put "a" text box, result is: a a a a a or sort... weird. here code:
in jsp here portion inside of "head":
<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>disti tool wireframe</title> <script type="text/javascript" src="${pagecontext.request.contextpath}/js/disti.js"></script> <link rel="stylesheet" href="${pagecontext.request.contextpath}/css/style.css" /> <link rel="stylesheet" href="${pagecontext.request.contextpath}/css/styling.css" /> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> <link rel="stylesheet" href="${pagecontext.request.contextpath}/bootstrap/css/bootstrap-responsive.css" /> </head>
here body of code:
<div id = "label">country:</div> <div id ="txtentry"> <input type="text" id="country" data-provide="typeahead" autocomplete="off" class="span3" data-source='["afghanistan", "akrotiri", "albania", "algeria", "american samoa", "andorra", "angola", "anguilla", "antarctica", "antigua , barbuda", "argentina", "armenia", "aruba", "ashmore , cartier islands", "australia", "austria", "azerbaijan", "bahamas, the", "bahrain", "bangladesh" "barbados" "bassas da india", "belarus", "belgium", "belize", "benin", "bermuda", "bhutan", "bolivia", "bosnia , herzegovina", "botswana", "bouvet island", "brazil", "british indian ocean territory", "british virgin islands", "brunei", "bulgaria", "burkina faso", "burma", "burundi", "cambodia", "cameroon", "canada", "cape verde", "cayman islands", "central african republic", "chad", "chile", "china", "christmas island", "clipperton island", "cocos (keeling) islands", "colombia", "comoros", "congo, democratic republic of the", "congo, republic of the", "cook islands", "coral sea islands", "costa rica", "croatia", "cuba", "cyprus", "czech republic", "denmark", "dhekelia", "djibouti", "dominica", "dominican republic", "ecuador", "egypt", "el salvador", "equatorial guinea", "eritrea", "estonia", "ethiopia", "europa island", "falkland islands (islas malvinas)", "faroe islands", "fiji", "finland", "france", "french guiana", "french polynesia", "french southern , antarctic lands", "gabon", "gambia, the", "gaza strip", "georgia", "germany", "ghana", "gibraltar", "glorioso islands", "greece", "greenland", "grenada", "guadeloupe", "guam", "guatemala", "guernsey", "guinea", "guinea-bissau", "guyana", "haiti", "heard island , mcdonald islands", "holy see (vatican city)", "honduras", "hong kong", "hungary", "iceland", "india", "indonesia", "iran", "iraq", "ireland", "isle of man", "israel", "italy", "jamaica", "jan mayen", "japan", "jersey", "jordan", "juan de nova island", "kazakhstan", "kenya", "kiribati", "korea, north", "korea, south", "kuwait", "kyrgyzstan", "laos", "latvia", "lebanon", "lesotho", "liberia", "libya", "liechtenstein", "lithuania", "luxembourg", "macau", "macedonia", "madagascar", "malawi", "malaysia", "maldives", "mali", "malta", "marshall islands", "martinique", "mauritania", "mauritius", "mayotte", "mexico", "micronesia, federated states of", "moldova", "monaco", "mongolia", "montserrat", "morocco", "mozambique", "namibia", "nauru", "navassa island", "nepal", "netherlands", "netherlands antilles", "new caledonia", "new zealand", "nicaragua", "niger", "nigeria", "niue", "norfolk island", "northern mariana islands", "norway", "oman", "pakistan", "palau", "panama", "papua new guinea", "paracel islands", "paraguay", "peru", "philippines", "pitcairn islands", "poland", "portugal", "puerto rico", "qatar", "reunion", "romania", "russia", "rwanda", "saint helena", "saint kitts , nevis", "saint lucia", "saint pierre , miquelon", "saint vincent , grenadines", "samoa", "san marino", "sao tome , principe", "saudi arabia", "senegal", "serbia , montenegro", "seychelles", "sierra leone", "singapore", "slovakia", "slovenia", "solomon islands", "somalia", "south africa", "south georgia , south sandwich islands", "spain", "spratly islands", "sri lanka", "sudan", "suriname", "svalbard", "swaziland", "sweden", "switzerland", "syria", "taiwan", "tajikistan", "tanzania", "thailand", "timor-leste", "togo", "tokelau", "tonga", "trinidad , tobago", "tromelin island", "tunisia", "turkey", "turkmenistan", "turks , caicos islands", "tuvalu", "uganda", "ukraine", "united arab emirates", "united kingdom", "united states", "uruguay", "uzbekistan", "vanuatu", "venezuela", "vietnam", "virgin islands", "wake island", "wallis , futuna", "west bank", "western sahara", "yemen", "zambia", "zimbabwe" ]'> </div>
and here @ bottom of body of code. have array in here twice since messing , trying see how make work. know having array in there twice redundant. i'm debugging.
<script src="http://code.jquery.com/jquery.js"></script> <script src="js/bootstrap.min.js"></script> <script type="text/javascript"> var location = ["afghanistan", "akrotiri", "albania", "algeria", "american samoa", "andorra", "angola", "anguilla", "antarctica", "antigua , barbuda", "argentina", "armenia", "aruba", "ashmore , cartier islands", "australia", "austria", "azerbaijan", "bahamas, the", "bahrain", "bangladesh" "barbados" "bassas da india", "belarus", "belgium", "belize", "benin", "bermuda", "bhutan", "bolivia", "bosnia , herzegovina", "botswana", "bouvet island", "brazil", "british indian ocean territory", "british virgin islands", "brunei", "bulgaria", "burkina faso", "burma", "burundi", "cambodia", "cameroon", "canada", "cape verde", "cayman islands", "central african republic", "chad", "chile", "china", "christmas island", "clipperton island", "cocos (keeling) islands", "colombia", "comoros", "congo, democratic republic of the", "congo, republic of the", "cook islands", "coral sea islands", "costa rica", "cote d'ivoire", "croatia", "cuba", "cyprus", "czech republic", "denmark", "dhekelia", "djibouti", "dominica", "dominican republic", "ecuador", "egypt", "el salvador", "equatorial guinea", "eritrea", "estonia", "ethiopia", "europa island", "falkland islands (islas malvinas)", "faroe islands", "fiji", "finland", "france", "french guiana", "french polynesia", "french southern , antarctic lands", "gabon", "gambia, the", "gaza strip", "georgia", "germany", "ghana", "gibraltar", "glorioso islands", "greece", "greenland", "grenada", "guadeloupe", "guam", "guatemala", "guernsey", "guinea", "guinea-bissau", "guyana", "haiti", "heard island , mcdonald islands", "holy see (vatican city)", "honduras", "hong kong", "hungary", "iceland", "india", "indonesia", "iran", "iraq", "ireland", "isle of man", "israel", "italy", "jamaica", "jan mayen", "japan", "jersey", "jordan", "juan de nova island", "kazakhstan", "kenya", "kiribati", "korea, north", "korea, south", "kuwait", "kyrgyzstan", "laos", "latvia", "lebanon", "lesotho", "liberia", "libya", "liechtenstein", "lithuania", "luxembourg", "macau", "macedonia", "madagascar", "malawi", "malaysia", "maldives", "mali", "malta", "marshall islands", "martinique", "mauritania", "mauritius", "mayotte", "mexico", "micronesia, federated states of", "moldova", "monaco", "mongolia", "montserrat", "morocco", "mozambique", "namibia", "nauru", "navassa island", "nepal", "netherlands", "netherlands antilles", "new caledonia", "new zealand", "nicaragua", "niger", "nigeria", "niue", "norfolk island", "northern mariana islands", "norway", "oman", "pakistan", "palau", "panama", "papua new guinea", "paracel islands", "paraguay", "peru", "philippines", "pitcairn islands", "poland", "portugal", "puerto rico", "qatar", "reunion", "romania", "russia", "rwanda", "saint helena", "saint kitts , nevis", "saint lucia", "saint pierre , miquelon", "saint vincent , grenadines", "samoa", "san marino", "sao tome , principe", "saudi arabia", "senegal", "serbia , montenegro", "seychelles", "sierra leone", "singapore", "slovakia", "slovenia", "solomon islands", "somalia", "south africa", "south georgia , south sandwich islands", "spain", "spratly islands", "sri lanka", "sudan", "suriname", "svalbard", "swaziland", "sweden", "switzerland", "syria", "taiwan", "tajikistan", "tanzania", "thailand", "timor-leste", "togo", "tokelau", "tonga", "trinidad , tobago", "tromelin island", "tunisia", "turkey", "turkmenistan", "turks , caicos islands", "tuvalu", "uganda", "ukraine", "united arab emirates", "united kingdom", "united states", "uruguay", "uzbekistan", "vanuatu", "venezuela", "vietnam", "virgin islands", "wake island", "wallis , futuna", "west bank", "western sahara", "yemen", "zambia", "zimbabwe" ]; $('#country').typeahead({source: location});
i used have
<input type="text" id="country" data-provide="typeahead" autocomplete="off" class="span3" data-source="location">
referring array of countries produced single result in typeahead.
please help... placement of jquery/bootstrap sources? wrong jquery call? i'm confused here. thank you.
looks there problem array, made array smaller , works now, can see here:
update forgot commas in array the updated array js fiddle, @ 'bangladesh' there problem
please recheck array
var location = ["afghanistan", "akrotiri", "albania", "algeria", "american samoa", "andorra", "angola", "anguilla", "antarctica", "antigua , barbuda", "argentina", "armenia", "aruba", "ashmore , cartier islands", "australia", "austria", "azerbaijan", "bahamas, the" ];
Comments
Post a Comment