<input id="form_topick_tags" />
<!-- Adjust the script tag locations per your set-up -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="GrowingInput.js" type="text/javascript" charset="utf-8"></script>
<script src="../Source/TextboxList.js" type="text/javascript" charset="utf-8"></script>
<script src="../Source/TextboxList.Autocomplete.js" type="text/javascript" charset="utf-8"></script>
<!-- required for TextboxList.Autocomplete if method set to 'binary' -->
<script src="../Source/TextboxList.Autocomplete.Binary.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var search = 'beatles',
myJSONArray = [];
$(function() {
var t = new $.TextboxList('#form_topick_tags', {
unique: true,
plugins: {
autocomplete: {
minLength: 2
}
}
});
$.ajax({
dataType:'JSONP',
success: function (obj) {
for (var i=0, orl=obj.result.length; i < orl; i++) {
var o = obj.result[i];
myJSONArray.push([o.guid, o.name, o.name+'<span>'+o['n:type'].name+'</span>']);
}
// For testing:
// alert(myJSONArray);
// You can just use myJSONArray, but if you need JSON, see http://json.org for a JSON converter; in modern browsers, JSON is supported by default
//alert(JSON.stringify(myJSONArray));
t.plugins['autocomplete'].setValues(myJSONArray);
},
url:
'http://www.freebase.com/private/suggest?type_strict=any&category=object&all_types=false&start=0&limit=10&prefix='+encodeURIComponent(search)
});
});
</script>