Skip to main content

Bug Tracker

Side navigation

#8738 closed bug (invalid)

Opened April 01, 2011 07:10AM UTC

Closed April 14, 2011 07:44PM UTC

Last modified April 14, 2011 08:21PM UTC

Click on anything but select

Reported by: smileart@mail.ru Owned by: smileart@mail.ru
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

I want to make the following functionality:

$(:not(select)).click(function()
{
    $('select').hide();
});

But I have a bug in Internet Explorer and Firefox (Windows, Ubuntu).

The bug is that when you install an event .click() with :not selector filter on select element, it's triggered when you click on arrow to open select list (bug is tested on Google Chrome and Firefox on Windows and in FF on Ubuntu, but in Google Chrome on Ubuntu all is ok!).

So, when you click arrow it's triggered an events on objects in background layers. For example if my select is in table, click will be called on: td, tr, tbody, body, html. So if I wanna hide select list with click on any other element it's will be hided even when I'll try just to open list.

I fix it temporary with the next code:

$(document).click(function(e)
{
     var target = e.target;

     if (!$(target).is('select'))
     {
            // code to hide select goes here
     }
});

But it's will be pretty good if click event on select will not call something else but click event on select :)

Attachments (0)
Change History (4)

Changed April 01, 2011 12:51PM UTC by dmethvin comment:1

owner: → smileart@mail.ru
status: newpending

Please provide a test case in jsFiddle.

Changed April 12, 2011 02:21PM UTC by anonymous comment:2

Replying to [comment:1 dmethvin]:

Please provide a test case in jsFiddle.

On jsFiddle it's looks like this:

http://jsfiddle.net/smileart/LDRCM/

Changed April 14, 2011 07:44PM UTC by addyosmani comment:3

resolution: → invalid
status: pendingclosed

Thanks for providing us with a reduced test case. :not(selector) is a filter and based on the way you're currently using it, you're going to select all of the elements on the page with the exception of your selected element (including td,tr,body etc etc). This will also (obviously) select the link you're using to trigger display of the select (your main problem here). Instead (and there are a number of ways to approach this), try including both the link and select as what you wish to exclude from your selection.

Technically this isn't a core issue (and you can get further assistance from our forums), so closing this ticket.

Changed April 14, 2011 08:21PM UTC by smileart@mail.ru comment:4

Yea, it's not a problem with link on jsFiddle. But if I wanna hide select in Firefox with click on any element except select by itself, it will be closed even when I click on arrow to open list of select. Is it normal control behavior?