5
<title>Example: Remote Data via YQL</title>
6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
<link rel="stylesheet" href="../assets/css/main.css">
8
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
<script src="../../build/yui/yui-min.js"></script>
14
<h1>Example: Remote Data via YQL</h1>
19
<div id="main" class="yui3-u">
20
<div class="content"><style scoped>
21
#ac-input { width: 250px; }
26
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.
31
<div id="demo" class="yui3-skin-sam">
32
<label for="ac-input">Search:</label><br>
33
<input id="ac-input" type="text">
37
YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) {
38
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
39
resultHighlighter: 'phraseMatch',
40
source: 'select * from search.suggest where query="{query}"',
41
yqlEnv: 'http://pieisgood.org/yql/tables.env'
50
<pre class="code prettyprint"><div id="demo" class="yui3-skin-sam">
51
<label for="ac-input">Search:</label><br>
52
<input id="ac-input" type="text">
53
</div></pre>
58
<pre class="code prettyprint">YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) {
59
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
60
resultHighlighter: 'phraseMatch',
61
source: 'select * from search.suggest where query="{query}"',
62
yqlEnv: 'http://pieisgood.org/yql/tables.env'
67
<h2>Complete Example Source</h2>
69
<pre class="code prettyprint"><div id="demo" class="yui3-skin-sam">
70
<label for="ac-input">Search:</label><br>
71
<input id="ac-input" type="text">
75
YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) {
76
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, {
77
resultHighlighter: 'phraseMatch',
78
source: 'select * from search.suggest where query="{query}"',
79
yqlEnv: 'http://pieisgood.org/yql/tables.env'
82
</script></pre>
87
<div id="sidebar" class="yui3-u">
93
<h2 class="no-toc">Examples</h2>
100
<li data-description="How to provide autocomplete suggestions from a local array.">
101
<a href="ac-local.html">Basic Local Data</a>
106
<li data-description="How to provide autocomplete suggestions using a remote JSONP source.">
107
<a href="ac-jsonp.html">Remote Data via JSONP</a>
112
<li data-description="How to provide autocomplete suggestions using a YQL query source.">
113
<a href="ac-yql.html">Remote Data via YQL</a>
118
<li data-description="How to provide autocomplete suggestions using a DataSource instance.">
119
<a href="ac-datasource.html">Remote Data via DataSource</a>
124
<li data-description="How to implement delimited tag completion.">
125
<a href="ac-tagging.html">Tag Completion Using Query Delimiters</a>
130
<li data-description="How to find and select Flickr photos using a YQL source and a custom autocomplete result formatter.">
131
<a href="ac-flickr.html">Find Photos on Flickr (Custom Formatting, YQL Source)</a>
136
<li data-description="How to use autocomplete-base to filter a set of existing items on a page.">
137
<a href="ac-filter.html">Filter a Set of Existing Items on a Page</a>
151
<script src="../assets/vendor/prettify/prettify-min.js"></script>
152
<script>prettyPrint();</script>