|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Remote Data via YQL</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<h1>Example: Remote Data via YQL</h1> |
|
|
25 |
<div class="yui3-g"> |
|
|
26 |
<div class="yui3-u-3-4"> |
|
|
27 |
<div id="main"> |
|
|
28 |
<div class="content"><style scoped> |
|
|
29 |
#ac-input { width: 250px; } |
|
|
30 |
</style> |
|
|
31 |
|
|
|
32 |
<div class="intro"> |
|
|
33 |
<p> |
|
|
34 |
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. |
|
|
35 |
</p> |
|
|
36 |
</div> |
|
|
37 |
|
|
|
38 |
<div class="example"> |
|
|
39 |
<div id="demo" class="yui3-skin-sam"> <!-- You need this skin class --> |
|
|
40 |
<label for="ac-input">Search:</label><br> |
|
|
41 |
<input id="ac-input" type="text"> |
|
|
42 |
</div> |
|
|
43 |
|
|
|
44 |
<script> |
|
|
45 |
YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) { |
|
|
46 |
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, { |
|
|
47 |
resultHighlighter: 'phraseMatch', |
|
|
48 |
source: 'select * from search.suggest where query="{query}"', |
|
|
49 |
yqlEnv: 'http://pieisgood.org/yql/tables.env' |
|
|
50 |
}); |
|
|
51 |
}); |
|
|
52 |
</script> |
|
|
53 |
|
|
|
54 |
</div> |
|
|
55 |
|
|
|
56 |
<h2>HTML</h2> |
|
|
57 |
<p> |
|
|
58 |
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the |
|
|
59 |
page's <code><body></code> element or to a parent element of the widget in order to apply |
|
|
60 |
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>. |
|
|
61 |
</p> |
|
|
62 |
<pre class="code prettyprint"><div id="demo" class="yui3-skin-sam"> <!-- You need this skin class --> |
|
|
63 |
<label for="ac-input">Search:</label><br> |
|
|
64 |
<input id="ac-input" type="text"> |
|
|
65 |
</div></pre> |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
<h2>JavaScript</h2> |
|
|
69 |
|
|
|
70 |
<pre class="code prettyprint">YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) { |
|
|
71 |
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, { |
|
|
72 |
resultHighlighter: 'phraseMatch', |
|
|
73 |
source: 'select * from search.suggest where query="{query}"', |
|
|
74 |
yqlEnv: 'http://pieisgood.org/yql/tables.env' |
|
|
75 |
}); |
|
|
76 |
});</pre> |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
<h2>Complete Example Source</h2> |
|
|
80 |
|
|
|
81 |
<pre class="code prettyprint"><div id="demo" class="yui3-skin-sam"> <!-- You need this skin class --> |
|
|
82 |
<label for="ac-input">Search:</label><br> |
|
|
83 |
<input id="ac-input" type="text"> |
|
|
84 |
</div> |
|
|
85 |
|
|
|
86 |
<script> |
|
|
87 |
YUI().use('autocomplete', 'autocomplete-highlighters', function (Y) { |
|
|
88 |
Y.one('#ac-input').plug(Y.Plugin.AutoComplete, { |
|
|
89 |
resultHighlighter: 'phraseMatch', |
|
|
90 |
source: 'select * from search.suggest where query="{query}"', |
|
|
91 |
yqlEnv: 'http://pieisgood.org/yql/tables.env' |
|
|
92 |
}); |
|
|
93 |
}); |
|
|
94 |
</script></pre> |
|
|
95 |
|
|
|
96 |
</div> |
|
|
97 |
</div> |
|
|
98 |
</div> |
|
|
99 |
|
|
|
100 |
<div class="yui3-u-1-4"> |
|
|
101 |
<div class="sidebar"> |
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
<div class="sidebox"> |
|
|
106 |
<div class="hd"> |
|
|
107 |
<h2 class="no-toc">Examples</h2> |
|
|
108 |
</div> |
|
|
109 |
|
|
|
110 |
<div class="bd"> |
|
|
111 |
<ul class="examples"> |
|
|
112 |
|
|
|
113 |
|
|
|
114 |
<li data-description="How to provide autocomplete suggestions from a local array."> |
|
|
115 |
<a href="ac-local.html">Basic Local Data</a> |
|
|
116 |
</li> |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
<li data-description="How to provide autocomplete suggestions using a remote JSONP source."> |
|
|
121 |
<a href="ac-jsonp.html">Remote Data via JSONP</a> |
|
|
122 |
</li> |
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
<li data-description="How to provide autocomplete suggestions using a YQL query source."> |
|
|
127 |
<a href="ac-yql.html">Remote Data via YQL</a> |
|
|
128 |
</li> |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
<li data-description="How to provide autocomplete suggestions using a DataSource instance."> |
|
|
133 |
<a href="ac-datasource.html">Remote Data via DataSource</a> |
|
|
134 |
</li> |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
<li data-description="How to implement delimited tag completion."> |
|
|
139 |
<a href="ac-tagging.html">Tag Completion Using Query Delimiters</a> |
|
|
140 |
</li> |
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
<li data-description="How to find and select Flickr photos using a YQL source and a custom autocomplete result formatter."> |
|
|
145 |
<a href="ac-flickr.html">Find Photos on Flickr (Custom Formatting, YQL Source)</a> |
|
|
146 |
</li> |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
<li data-description="How to use autocomplete-base to filter a set of existing items on a page."> |
|
|
151 |
<a href="ac-filter.html">Filter a Set of Existing Items on a Page</a> |
|
|
152 |
</li> |
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
<li data-description="How to find an address using a YQL source calling Google's Geocoding Service"> |
|
|
157 |
<a href="ac-geocode.html">Address Completion on Google's Geocoding Service</a> |
|
|
158 |
</li> |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
</ul> |
|
|
162 |
</div> |
|
|
163 |
</div> |
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
</div> |
|
|
168 |
</div> |
|
|
169 |
</div> |
|
|
170 |
</div> |
|
|
171 |
|
|
|
172 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
173 |
<script>prettyPrint();</script> |
|
|
174 |
|
|
|
175 |
<script> |
|
|
176 |
YUI.Env.Tests = { |
|
|
177 |
examples: [], |
|
|
178 |
project: '../assets', |
|
|
179 |
assets: '../assets/autocomplete', |
|
|
180 |
name: 'ac-yql', |
|
|
181 |
title: 'Remote Data via YQL', |
|
|
182 |
newWindow: '', |
|
|
183 |
auto: false |
|
|
184 |
}; |
|
|
185 |
YUI.Env.Tests.examples.push('ac-local'); |
|
|
186 |
YUI.Env.Tests.examples.push('ac-jsonp'); |
|
|
187 |
YUI.Env.Tests.examples.push('ac-yql'); |
|
|
188 |
YUI.Env.Tests.examples.push('ac-datasource'); |
|
|
189 |
YUI.Env.Tests.examples.push('ac-tagging'); |
|
|
190 |
YUI.Env.Tests.examples.push('ac-flickr'); |
|
|
191 |
YUI.Env.Tests.examples.push('ac-filter'); |
|
|
192 |
YUI.Env.Tests.examples.push('ac-geocode'); |
|
|
193 |
|
|
|
194 |
</script> |
|
|
195 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
</body> |
|
|
200 |
</html> |