Well I tried

$(document).click(function(event)
{
       if(!$(event.target).is($('#' + self.options.auto_complete_id),
self.element))
       {
                alert(event.target);
                $('#' + self.options.auto_complete_id).css('display', 'none');
        }
});

and that does work for closing the auto complete box.  I am also getting
"t.substring is not a function" error


Karl Swedberg-2 wrote:
> 
> 
> Not sure about your particular situation, but one thing you might  
> consider is event delegation. Pseudo-code:
> 
> $(document).click(function(event) {
>       if ( !$(event.target).is('your autocomplete box, the input box') {
>               // close the autocomplete box
>       }
> });
> 
> so, on clicking anywhere in the document, if the click is not on the  
> autocomplete or input box, you close the autocomplete box. Is that  
> what you're looking for?
> 
> 
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
> 
> 
> 
> On Feb 3, 2008, at 10:43 AM, Eridius wrote:
> 
>>
>>
>> I have create an auto complete plug-in the it almost prefect for  
>> what I need,
>> just one small problem.  The problem is that I can't get the auto  
>> complete
>> box to disappear when i click click outside of the input box and  
>> outside the
>> auto complete box.  now my first try was to do a blur event on the  
>> input box
>> which does the job but since the blur event happens before  
>> the .click event
>> on the auto complete items, the auto complete box disappear before  
>> the click
>> event happens.  Is there another way to hide the auto complete box  
>> when i
>> click outside the input and auto complete box?
>>
>> Also, please don't respond by saying use "X" plug-in instead.  I  
>> know that a
>> lot of people don't like when people recreate the "wheel"(i don't  
>> really
>> understand it.  I have recreated a plug-in(a tab plug-in) and the  
>> reason I
>> am re create a auto complete plug-in(and I am sure there will be  
>> more) is I
>> want to actually learn jQuery.  I don't want to have to be dependent  
>> on
>> another person work.  Also the plug-ins that i create and recreate I  
>> am
>> actually interested in learn how they really work.  Know I am not  
>> someone is
>> is trying to create every plug-in under the sun, for instance I  
>> would never
>> think about recreating a form validation plug or thickbox plug-in  
>> because I
>> can find fantastic plug-in that do that and I really have no deep  
>> need to
>> learn those from scratch.
>> -- 
>> View this message in context:
>> http://www.nabble.com/problem-doing-auto-complete-tp15254596s27240p15254596.html
>> Sent from the jQuery General Discussion mailing list archive at  
>> Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/problem-doing-auto-complete-tp15254596s27240p15261661.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to