Thanks! Unfortunately I still work in a jQuery-less environment, but that's changing :)
cheers, - ricardo On Nov 22, 2:14 am, Karl Swedberg <[EMAIL PROTECTED]> wrote: > One very minor note: you don't need to do this: > > var elm = e.target || e.srcElement; > > this is fine: > > var elm = e.target; > > jQuery normalizes the target property. From the core file ... > > // Fix target property, if necessary > if ( !event.target ) > event.target = event.srcElement || document; // Fixes > #1925 where > srcElement might not be defined either > > Cheers, > > --Karl > > On Nov 21, 2008, at 7:05 PM, ricardobeat wrote: > > > > > By the way, you could use event delegation to simplify things a lot: > > > $(document).ready(function(){ > > $('body').mouseover(function(e){ > > var elm = e.target || e.srcElement; > > if ( !$(elm).parents('.ui-dialog').length ) { //if .ui-dialog > > is not an ancestor > > $(elm).doStuff(); > > } > > }); > > }); > > > It might be slower than binding the function straight to each element, > > but it will pay off on very large DOMs. > > > - ricardo > > > On Nov 21, 8:07 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > >> My mistake, it is working. The problem was my lack of understanding > >> about how Dialog works. main is the div from which I create a Dialog > >> and I didn't want the event listener to be added to the elements of > >> main. However main is NOT the first element of the Dialog. I the > >> background it is wrapped around other elements and the top one has > >> class .ui-dialog . All sorted. Thanks . > > >> On 21 nov, 09:32, "[EMAIL PROTECTED]" > > >> <[EMAIL PROTECTED]> wrote: > >>> It still doesn't work. I think part of the problem is because the > >>> children of main are added after I create the event listener. > > >>> Second solution is to check in the event listener if the target is a > >>> child of main and if so, return. I know how to get the children of > >>> main , but how to I check the current tartget is one of them ? > > >>> ricardobeat> I need to select all objects of the page because I want > >>> to do a DOM inspector. But yes you are right, maybe I should only > >>> start from body ! > > >>> Thanks > > >>> On 20 nov, 18:25, ricardobeat <[EMAIL PROTECTED]> wrote: > > >>>> Are you sure you want to apply it to *all* elements on the page? > >>>> That > >>>> sounds a bit awkward. > > >>>> var main = $('#main, #main *'); > >>>> $('body *').not(main).mouseover(function(){...}); > > >>>> On Nov 20, 2:07 pm, "[EMAIL PROTECTED]" > > >>>> <[EMAIL PROTECTED]> wrote: > >>>>> Hi, > > >>>>> I want to apply a mouseover event on all elements but one and its > >>>>> children. I can't use class name to filter. How can I do it ? > >>>>> I've > >>>>> tried unsuccessfully : > > >>>>> $("*:not(#main)").not($ > >>>>> ("#main").children()).mouseover(function() { > > >>>>> }); > > >>>>> thanks