5
<title>Example: Remote Data via YQL</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: Remote Data via YQL</h1>
20
<div class="yui3-u-3-4">
22
<div class="content"><style scoped>
23
#ac-input { width: 250px; }
28
This example demonstrates how to provide autocomplete suggestions using a YQL query as the source. In this case, we're using a custom <a href="http://developer.yahoo.com/yql/console/?q=select%20*%20from%20search.suggest%20where%20query%3D%22yui%20autocomplete%22&env=http%3A%2F%2Fpieisgood.org%2Fyql%2Ftables.env"><code>search.suggest</code> YQL table</a> to provide suggestions based on popular Yahoo! Search queries.
33
<div id="demo" class="yui3-skin-sam">
34
<label for="ac-input">Search:</label><br>
35
<input id="ac-input" type="text">
39
YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) {
40
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
41
resultHighlighter: 'phraseMatch',
42
source: 'select * from search.suggest where query="{query}"',
43
yqlEnv: 'http://pieisgood.org/yql/tables.env'
52
<pre class="code prettyprint"><div id="demo" class="yui3-skin-sam">
53
<label for="ac-input">Search:</label><br>
54
<input id="ac-input" type="text">
55
</div></pre>
60
<pre class="code prettyprint">YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) {
61
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
62
resultHighlighter: 'phraseMatch',
63
source: 'select * from search.suggest where query="{query}"',
64
yqlEnv: 'http://pieisgood.org/yql/tables.env'
69
<h2>Complete Example Source</h2>
71
<pre class="code prettyprint"><div id="demo" class="yui3-skin-sam">
72
<label for="ac-input">Search:</label><br>
73
<input id="ac-input" type="text">
77
YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) {
78
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
79
resultHighlighter: 'phraseMatch',
80
source: 'select * from search.suggest where query="{query}"',
81
yqlEnv: 'http://pieisgood.org/yql/tables.env'
84
</script></pre>
90
<div class="yui3-u-1-4">
97
<h2 class="no-toc">Examples</h2>
101
<ul class="examples">
104
<li data-description="How to provide autocomplete suggestions from a local array.">
105
<a href="ac-local.html">Basic Local Data</a>
110
<li data-description="How to provide autocomplete suggestions using a remote JSONP source.">
111
<a href="ac-jsonp.html">Remote Data via JSONP</a>
116
<li data-description="How to provide autocomplete suggestions using a YQL query source.">
117
<a href="ac-yql.html">Remote Data via YQL</a>
122
<li data-description="How to provide autocomplete suggestions using a DataSource instance.">
123
<a href="ac-datasource.html">Remote Data via DataSource</a>
128
<li data-description="How to implement delimited tag completion.">
129
<a href="ac-tagging.html">Tag Completion Using Query Delimiters</a>
134
<li data-description="How to find and select Flickr photos using a YQL source and a custom autocomplete result formatter.">
135
<a href="ac-flickr.html">Find Photos on Flickr (Custom Formatting, YQL Source)</a>
140
<li data-description="How to use autocomplete-base to filter a set of existing items on a page.">
141
<a href="ac-filter.html">Filter a Set of Existing Items on a Page</a>
156
<script src="../assets/vendor/prettify/prettify-min.js"></script>
157
<script>prettyPrint();</script>