Hi, First I still use protototype 1.5.1. I''m creating something like that using prototype and script.aculo.us --------------------------------------------------------------------------------------- <div id="divLangue" class="listeACocher"> <input type="hidden" id="Langue" name="Langue" /> <input type="text" id="txtLangue" name="txtLangue" /> <ul> <li class="impaire"><input type="checkbox" id="chkLangue1" name="chkLangue" value="1" /> français</li> <li class="paire"><input type="checkbox" id="chkLangue2" name="chkLangue" value="2" /> anglais</li> <li class="impaire"><input type="checkbox" id="chkLangue3" name="chkLangue" value="3" /> allemand</li> <li class="paire"><input type="checkbox" id="chkLangue4" name="chkLangue" value="4" /> espagnol</li> <li class="impaire"><input type="checkbox" id="chkLangue5" name="chkLangue" value="5" /> italien</li> </ul> </div> --------------------------------------------------------------------------------------- The problem is : I would like to handle the $(''divLangue'') mouseout event. I have obviously some problems with event bubbling. If I leave one <li> to another one, it fires the $(''divLangue'') mouseout event. I tried to use Event.stop(e) but I didn''t see any changes. I didn''t succeed, as well, to find if elements have the same ancestor to don''t fire the event. I found a very interesting post, it inspired me, but I failed and I''m writing here now! http://groups.google.fr/group/rubyonrails-spinoffs/browse_frm/thread/18e678f63fd39658/d0a3ab56d805f706?hl=fr&lnk=gst&q=event.observe+bubble#d0a3ab56d805f706 Here is a small and obvious code with Event.stop(e), right now I can''t do better... --------------------------------------------------------------------------------------- Event.observe($("divLangue"), "mouseout", function (e) { var $elm = Event.element(e); Event.stop(e); alert($elm.ancestors()); }); --------------------------------------------------------------------------------------- Do you see what''s I''m doing wrong? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
based on this: http://github.com/savetheclocktower/javascript-stuff/tree/master/custom-events/mouse_enter_leave.js ... ''mouseout'', function(e){ var target= Event.element(e); if (e.relatedTarget && !e.relatedTarget.descendantOf(target)){ //do your code here } }); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
might have to use !Element.descendantOf(e.relatedTarget, target) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Well done! Actually I have to check if it''s a descendant of the ancestor and not the target : ---------------------------------------- if (/MSIE/.test(navigator.userAgent)) { // I still use prototype v1.5.1 Event.observe($("divLangue")), "mouseleave", function (e) { alert(""); }); } else { Event.observe($("divLangue")), "mouseout", function (e) { if (e.relatedTarget && !e.relatedTarget.descendantOf($ ("divLangue"))) { alert(""); } }); } ---------------------------------------- Unfortunately, I get an exception with Firefox : "''Permission denied to get property HTMLDivElement.parentNode'' when calling method: [nsIDOMEventListener::handleEvent]" which I "prevent" with a try catch. Thanks à lot. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---