0

I have the following code that works perfectly :

$("#element1").autocomplete({  
    source: function (request, response) {
         $.ajax({
             url: "https://jsonurlworks.com",
             type: "GET",
             data: { q: request.term },
             //data: request,
             success: function (data) {
                 response($.map(data.data, function (el) {
                     return {
                    label: el.name,
                    value: el.country_code,
            size: el.audience_size
                     };
                 }));
             }
         });
    },
    select: function (event, ui) {
        // Prevent value from being put in the input:
        this.value = ui.item.label;


        // Set the next input's value to the "value" of the item.
      //  $(this).next("input").value(ui.item.value);

        $('#asize').text("("+ui.item.size+")");

        event.preventDefault();
    }
});

Well it shows the list of el.name. I would like to add size right next to name. for example Title (#18374),something along these lines. any suggestions please?

Fran Verona
  • 5,438
  • 6
  • 46
  • 85
cppit
  • 4,478
  • 11
  • 43
  • 68
  • possible duplicate of [jQueryUI: how can I custom-format the Autocomplete plug-in results?](http://stackoverflow.com/questions/2435964/jqueryui-how-can-i-custom-format-the-autocomplete-plug-in-results) – cppit Mar 06 '14 at 03:47
  • Is this what you want? http://jsfiddle.net/franverona/gNd6D/ (add some string to selected value) – Fran Verona Mar 07 '14 at 14:26

0 Answers0