Jörn Zaefferer wrote:
Robert O'Rourke wrote:
I see what you mean, I'll keep trying to work it out in the meantime.
That show event trigger didn't seem to work, it's on the demo page
now. It might be a bit beyond my abilities at the moment but we shall
see.
Looks like you got it working.
Could you tell me what you changed to achieve that?
Hi Jörn,
The main difference was changing the .click event on $input to give
the input focus and then added an else statement to it:
.click(function() {
jQuery(this).focus(); // give it focus straight away so it opens up
// show select when clicking in a field, hide it if it's already open
if ( hasFocus++ > 1 && !select.visible() ) {
onChange(0, true);
} else {
select.hide(); // added this to create open and close option
}
})
I've changed that now though. The behaviour I have now ( depending
on the options chosen ) is the same as the address bar in firefox.
I've been editing it quite heavily, and took your advice to
integrate my changes into the autocomplete plugin more. It's ropey still
and a little bit specific to the way my employers cms works... I've
tried to generalise it more, making it into a plugin in its own right
although I'm certain I'm not doing things quite right.
What I'm doing is to forget about having the link opening and
closing the box, instead I'm adding extra behaviour to the text input so
it now has an open class, a closed class and a hover class to allow me
to mimick a select box. See the CSS inline.
I currently have one issue I'm aware of where if you click in the
input it selects the text the first time but then if you click out of it
and then back onto it the text is selected briefly then the caret skips
to the end and deselects the text. Sorry if that's not too clear.
It's underway at least. Also I fixed the mustMatch option:
function stopLoading() {
$input.removeClass(options.loadingClass);
if ( options.mustMatch ) {
select.hide();
}
}