--- jquery.autocomplete.js 2009-08-10 13:02:21.000000000 +1200 +++ 03_jquery.autocomplete.js-json 2009-08-10 16:26:05.000000000 +1200 @@ -386,6 +386,7 @@ }; function parse(data) { + if (options.dataType == "json") return parseJSON(data); var parsed = []; var rows = data.split("\n"); for (var i=0; i < rows.length; i++) { @@ -402,6 +403,19 @@ return parsed; }; + function parseJSON(data) { + for (var i=0; i < data.length; i++) { + var row = data[i]; + var formatted = options.formatResult && options.formatResult(row) || row.formatted; + data[i] = { + data: row, + value: formatted, + result: formatted + }; + } + return data; + }; + function stopLoading() { $input.removeClass(options.loadingClass); }; @@ -422,7 +436,7 @@ mustMatch: false, extraParams: {}, selectFirst: true, - formatItem: function(row) { return row[0]; }, + formatItem: function(row) { return row.formatted && row.formatted || row[0] }, formatMatch: null, autoFill: false, width: 0,