Created
January 15, 2011 23:54
-
-
Save joerussbowman/781383 to your computer and use it in GitHub Desktop.
Example yui3 autocomplete using yql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" name="q" id="q" /> | |
<script type="text/javascript"> | |
YUI().use("autocomplete", "autocomplete-highlighters", "datasource-get", function (Y) { | |
var acDS = new Y.DataSource.Get({ | |
source: "http://sugg.search.yahoo.com/gossip-us-fp/?nresults=10&queryfirst=2&output=json&version=&command=", | |
}); | |
Y.one('#q').plug(Y.Plugin.AutoComplete, { | |
maxResults: 10, | |
resultHighlighter: 'phraseMatch', | |
requestTemplate: "{query}", | |
resultListLocator: 'gossip.results', | |
resultTextLocator: 'key', | |
source: acDS | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DataSource.Get requires a response wrapped in a JSONP callback. The sugg.search API doesn't let you specify a custom JSONP callback, so this can't work. You'll have to go through YQL to get past the same domain restriction.