| Page 1 of 1 | [ 2 posts ] |
|
I'm really confusing myself here reading the Autocomplete documentation.
I'm using a DataSource.IO instance to use as my Autocomplete's source, and I'm trying to configure the ResultsListLocator. From the examples, the response objects seem like pure JSON data, but my response object is an array of XMLHttpRequest objects. I know that my actaul response JSON should look like: Quote: { "items": ['one','two','three'], "numRows": 1 } Therefore I WANT to just set my ResultListLocator to "items". Unfortunately, that does not work, and upon inspecting what the response object actually looks like, it looks like the FireBug screenshot below: ![]() Do I really have to type a big resultListLocator function to penetrate this response object? I tried plugging the datasource-jsonschema into the datasource instance, but that caused my resultListLocator function to never even get called. Any ideas? |
|
When you use a DataSource as an AutoComplete source, it's generally best to process the response into a usable format using a DataSchema of some kind so that the object that ultimately gets passed from the DataSource to AutoComplete is something AutoComplete can handle (or at least close to it). Mixing a DataSource with AutoComplete's own result locating functionality can make it hard to understand which part of a response is being processed in which place. DataSchemas do take some configuration though (they don't just magically know what to do with your data).
In this case, it looks like the DataSource is returning an array with an unparsed XMLHttpRequest object as the first item. You would need to extract that item's `responseText`, parse it as JSON to get an object, and *then* AutoComplete would be able to operate on that object. If you're not taking advantage of the DataSource to provide data to multiple components or to perform some kind of complex schema processing, then I'd recommend getting rid of it and just letting AutoComplete handle the XHR requests itself. It will then automatically parse the responses into objects, and you can set your resultListLocator to the string "response.items" (no function needed). |
| Page 1 of 1 | [ 2 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group