1

This is my data source in JSON format:

{
"list-1":
    [{"id":"1","value":"andy"},{"id":"2","value":"sandy"}],
"list-2":
    [{"id":"1","value":"candy"},{"id":"2","value":"brandy"}],
"list-3":
    [{"id":"1","value":"mandy"},{"id":"2","value":"dandy"}]
}

And I'm trying to get following output:

<div id="result">
    <ul class="list-1">
        <li>andy</li>
        <li>sandy</li>
    </ul>
    <ul class="list-2">
        <li>candy</li>
        <li>brandy</li>
    </ul>
    <ul class="list-3">
        <li>mandy</li>
        <li>dandy</li>
    </ul>
</div>

The default data source (JSON format) which works is as follow: [{"id":"1"},{"foo":"bar"}], I haven't been able to find a good/easy to follow documentation/tutorials on how to retrieve multidimensional data arrays.

Can anyone please shed some light for me on this, what do I need to modify/override within JQuery AutoComplete plug-in to achieve this output (within Select or Success event? or should I modify the rendering part and how)

Thanks in advance

Nick Germi
  • 403
  • 3
  • 6
  • 15
  • This is an example running code with customised output and default single dimension data http://codepen.io/anon/pen/FqEJt (Thanks to http://stackoverflow.com/a/2746987/2518765) – Nick Germi Jun 26 '13 at 01:29
  • I've found a workaround, edited the data source making it single dimensional and added `type` to each item, and then in renderItem function I check for the type, if the type is `list=1` I append the item to my custom UL with the ID `list-1`. While this works this is not exactly what I was after and I'll leave the question here in case if someone comes up with better idea. code in the next comment. – Nick Germi Jun 26 '13 at 03:33
  • `jQuery("#toplivesearch").data("autocomplete")._renderItem = function( ul, item ) { var container; if(item.type == "list-1"){ container = $("#list-1"); } if(item.type == "list-2") { container = $("#list2"); } if(item.type == "list-3") { container = $("#list-3"); } return $("
  • ").data("item.autocomplete", item).append("" + item.label + "").appendTo(container); };` You have to create your own UL's in the html `
        `and so on At the end you'll end up with an extra empty UL which you can hide. – Nick Germi Jun 26 '13 at 03:39