i'm trying implement yui's autocomplete widget, can't display want properly.
here's call pulls json object
var datasource = new y.datasource.io({ source: '/search' }); y.one('#search-string').plug(y.plugin.autocomplete, { resulthighlighter: 'phrasematch', resulttextlocator: 'response', requesttemplate: '?search-string={query}', source: acdatasource, maxresults: 5 } but entire object displayed in autocomplete box
{ "content": [ { "name": "billy bob", "id": 155, "address": "123 little billy ln", } } i trying display "name" values, not whole object. ideas?
you need set resultlistlocator , set resulttextlocator correctly. documentation
while autocomplete automatically knows how handle results come simple array, needs information in order find result array that's buried inside object hierarchy. that's resultlistlocator config attribute comes in.
and
the resulttextlocator config attribute can used tell autocomplete how find text within individual result object, resultlistlocator attribute tells autocomplete how find array of results within response object.
by way, seem have mistyped json - array not closed. assuming content results array
resultlistlocator: 'content', resulttextlocator: 'name', should working
Comments
Post a Comment