views:

57

answers:

2

Any jquery autocomplete plugin which consumes this json format?

{"Table" : [{"ClientName" : "Pandiya"},
{"ClientName" : "Bala"}]}

or how to change the above to

source: ["Pandiya", "Bala"]
+1  A: 

As far as I know, the one in jQuery UI lets you define a custom callback, in which you can do any filtering and transforms you like on the results, and convert your results to the format the widget likes.

Matti Virkkunen
@Matti i dont want a call back function... I want my plugin to just come that json data...
Pandiya Chendur
...why not? Do you really think it'd be a good idea to create separate jQuery plugins for each and every data format there is? A callback function is the most flexible way.
Matti Virkkunen
@Matt i agree with you, i did it with yui but not with jquery?
Pandiya Chendur
@Pandiya Chendur: I... have no idea what that is supposed to mean
Matti Virkkunen
@Matti please see my edit... I have this json string returned from my aspx page....
Pandiya Chendur
A: 

It would be very easy to handle this with the jQuery UI autocomplete plugin:

var list = {"Table" : [{"ClientName" : "Pandiya"},{"ClientName" : "Bala"}]};
$("#autcomplete").autocomplete({
    source: $.map(list.Table, function(item) {
                return {
                    label: item.ClientName,
                    value: item.ClientName
                }
            })
});
PetersenDidIt
@petersen there will be no url.... Just the json data alone... Please see my edit... I need to change json string to that format..
Pandiya Chendur
@Pandiya updated my answer
PetersenDidIt