[jQuery] [autocomplete] Calling decodeURIComponent

[jQuery] [autocomplete] Calling decodeURIComponent


Hello!
I've recently become involved with a project where we use the jQuery
Autocomplete plugin, and It's been working like a charm except for one
thing.
On our backend code we output data in an url encoded format (space
becomes %20 and so on), and in our jQuery code we want to decode this
to be more readable. To fix this in the autocomplete list we can
specify the formatItem option to a callback function which decodes the
data, but when the users selects a value from the list the data being
put into the input field is still not decoded.
I've tried specifying the formatResult, like so:
formatResult: function(data) { return decodeURIComponent(data[0]); }
That doesn't seem to work properly though, and perhaps I've
misunderstood exactly what formatResult does. I've tried looking at
what is being passed to the formatResult callback by specifying it to
alert or console.log, but that just gives me errors.
If there would be a way of specifying like a global formatting
function for the entire autocomplete plugin that would be great, since
all data needs to be decoded before display. Any help on this is
greatly appreciated.
/Viktor Rutberg