On 4/7/09 1:00 PM, "skunkwerk" <skunkw...@gmail.com> wrote:

>    i'm using the autocomplete plugin here (http://docs.jquery.com/
> Plugins/Autocomplete) and want to be able to use it with a remote URL,
> while at the same time having access to have text displayed one way,
> and selected another way (ie display a piece of text, but then change
> what is entered into the input box once it's selected)
> 
> with local data you can do this:
> var data = [ {text:'Link A', url:'/page1'}, {text:'Link B', url: '/
> page2'} ];
> formatItem: function(item) {
>     return item.text;
>   }
> 
> but how do I do this for a remote URL?  the remote server is supposed
> to return a bunch of matches separated by newline characters, but how
> do I embed multiple fields in the results?

if the value you to enter into the form's input element can be derived
programmatically from the suggested text then you could make the
modification using the formatResult option. there are examples of its use in
the demo: http://view.jquery.com/trunk/plugins/autocomplete/demo/

if the value you want isn't derivable from the suggestions then the simples
answer is probably to make it so. you could put both the suggestion text and
the input value suitably marked up into each line of remote results. then
use formatItem to hide the input value in the suggestion list and use
formatResult to extract it.


Reply via email to