views:

35

answers:

1

I'm creating an autocomplete on a web page using jQuery's AutoComplete plugin.

Does anyone know how to make the list show, if for example, someone has entered 3 characters, then clicked out of the input box, but then goes back to it?

$("#details_business_trade").autocomplete({
    source: resultsSplit,
    autoFill: true,
    mustMatch: true,
    close: function() { $("#createProspect").validate().element("#details_business_trade"); },
    mustMatch: true
});

This is my code so far...

A: 

You can trigger a search using the current value when it's re-focused by using the search method, like this:

$("#details_business_trade").autocomplete({
    source: resultsSplit,
    autoFill: true,
    mustMatch: true,
    close: function() { $("#createProspect").validate().element("#details_business_trade"); },
    mustMatch: true
}).focus(function() {
    $(this).autocomplete("search");
});

It's not your example, but here's a jQuery UI Demo updated with the same concept, search for "act" for example.

Nick Craver
Thanks, but that doesn't seem to work.
Sjwdavies
Basically, if the user has entered 'Art' then clicked out of the input box, but go back to it, it shows immediately the relevant matches...
Sjwdavies
@Sjwdavies - Ah, I see what you're after, one moment :)
Nick Craver
@Sjwdavies - Updated with what I think you're after, give it a shot :)
Nick Craver
@Nick Craver: That's awesome, you've no idea how long i've been trying to figure this out! Thanks Buddy!
Sjwdavies
@Sjwdavies - welcome!
Nick Craver
@ Nick Craver: Off original thread, but do you know how I can make the list a scrollable one?
Sjwdavies
@Sjwdavies - Check this out: http://jsfiddle.net/nick_craver/v3bXn/1/ should test it in IE to make sure though.
Nick Craver
@Nick Craver: That's very cool but I was thinking more along the lines of 'scroll: true' or something ?
Sjwdavies
@Sjwdavies - There's no built-in support for it yet, it has been requested by the community quite a bit though, so we should see it in a future jQuery UI release.
Nick Craver
@Nick Craver: Nick, I've checked this in IE this morning, and unfortunately your fix doesn't work. It works fine in FF, but when I click on a suggestion from the drop down list - IE still shows the list item. So i've got the answer in my text box, but also a single element in the drop down list - the same as the one in my text box... Is there a way to hide it if the list item is the same as the contents of the text box?
Sjwdavies