I've got an application where I need the select list (the dropdown
menu) to be created inside the parent of the input object, rather than
at the end of the body.

Briefly: we're doing an autocomplete box inside a spring-loaded "fly-
out" element.  The element is shown by a hover event.  When the cursor
is moved out of the element, it is hidden.  When the autocomplete list
is at the end of the body, moving the cursor over it causes the the
fly-out element to be hidden.

(Not my design, I just have to implement it!)

I came up with the following simple mods to jquery.autocomplete.js
that seem to accomplish what I want.  Are there some hidden gotchas
that will bite me later?  Is this something that could be added as an
option?

In $.Autocomplete.Select().init(), change the argument to appendTo,
below:

                element = $("<div/>")
                .hide()
                .addClass(options.resultsClass)
                .css("position", "absolute")
                .appendTo($(input).parent());

in $.Autocomplete.Select().show(), change the initialization of the
var "offset" to use position() rather than offset():

                        var offset = $(input).position();

Reply via email to