Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#8738 closed bug (invalid)

Click on anything but select

Reported by: smileart@… Owned by: smileart@…
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 :)

Change History (4)

comment:1 Changed 8 years ago by dmethvin

Owner: set to smileart@…
Status: newpending

Please provide a test case in jsFiddle.

comment:2 in reply to:  1 Changed 8 years ago by anonymous

Replying to dmethvin:

Please provide a test case in jsFiddle.

On jsFiddle it's looks like this: http://jsfiddle.net/smileart/LDRCM/

comment:3 Changed 8 years ago by addyosmani

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.

comment:4 Changed 8 years ago by smileart@…

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?

Note: See TracTickets for help on using tickets.