Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have not been able to get formatMatch and formatResult to work so far. I am still working on the 'correct' way to use them. However, as a workaround you can use the parse option as follows. Just to be clear, in this example, formatItem and parse are functional while formatResult and formatMatch are not functional.</p> <pre><code>jQuery(function(){ $('#profile-tabs_addresses_grid_b_a_PostalCode').autocomplete ('http://test.mydomain.com/locality/postalcodes/', { minChars:1, delay:400, cacheLength:100, matchContains:true, max:10, formatItem:function(item, index, total, query){ return item.PostalCode + ': ' + item.Region + ', ' + item.City + ', ' + item.Country; }, formatMatch:function(item){ return item.PostalCode; }, formatResult:function(item){ return item.PostalCode; }, dataType:'json', parse:function(data) { return $.map(data, function(item) { return { data: item, value: item.PostalCode, result: item.PostalCode } }); }}); }); </code></pre> <p>here is the json data that comes back from the data url ( whitespace added for easier viewing ):</p> <pre><code>[ {City:"St. Louis", Country:"USA", PostalCode:"63103", ID:3, Region:"Missouri"}, {City:"St. Louis", Country:"USA", PostalCode:"63109", ID:1, Region:"Missouri"}, {City:"St. Louis", Country:"USA", PostalCode:"63119", ID:2, Region:"Missouri"} ] </code></pre> <p>When I type a 6 in the postal code box, it shows all three options properly formatted as:</p> <pre><code>63103: Missouri, St. Louis, USA 63109: Missouri, St. Louis, USA 63119: Missouri, St. Louis, USA </code></pre> <p>and when I select one the textbox receives just the selected postal code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload