This is very very cool, and something I spent several hours trying to figure out last night. Synchronicity! Can you explain a little more (for someone who doesn't understand custom events at all) what this magic is? I can see that it works, precisely the same way as Nick's for all intents and purposes. But what I fail to understand is how a custom event is observed. I don't see anything in your code that extends Event.Observe to add these events.
Could you elaborate, please? Thanks, Walter On Oct 1, 2008, at 1:15 PM, [EMAIL PROTECTED] wrote: > > here's a version that uses custom events: > http://neverninetofive.com/mouseenterleave/ > > Nick, hope you don't mind, i borrowed your testing template. > > On Sep 21, 12:59 pm, Nick Stakenburg <[EMAIL PROTECTED]> wrote: >> That will probably give you some problems with textarea's and input >> elements. I've created a patch that allows observe to handle >> mouseenter and mouseleave so you can do: >> >> $(element).observe('mouseenter', function() { alert('entered'); }); >> $(element).observe('mouseleave', function() { alert('left'); }); >> >> patch:http://prototype.lighthouseapp.com/projects/8886/tickets/350 >> demo:http://www.nickstakenburg.com/tests/enterleave/ >> >> -- >> Nick >> >> On 19 sep, 14:41, Julien <[EMAIL PROTECTED]> wrote: >> >>> Element.addMethods({ >>> onmouseenter: function(element,observer) { >>> element = $(element); >>> element.observe('mouseover', >>> function(evt,currentTarget) { >>> var relatedTarget = $ >>> (evt.relatedTarget || evt.fromElement); >>> if( relatedTarget! >>> =currentTarget && relatedTarget.childOf(currentTarget)==false ) >>> observer(element); >>> }.bindAsEventListener >>> ({},element)); >>> return element; >>> }, >>> onmouseleave: function(element,observer) { >>> element = $(element); >>> element.observe('mouseout', >>> function(evt,currentTarget) { >>> var relatedTarget = $ >>> (evt.relatedTarget || evt.toElement); >>> if(relatedTarget! >>> =currentTarget && >>> relatedTarget.childOf(currentTarget)==false )observer(element); >>> }.bindAsEventListener >>> ({},element)); >>> return element; >>> } >>> }); >> >>> it's work >> >>> On 19 sep, 13:12, Julien <[EMAIL PROTECTED]> wrote: >> >>>> Hello >> >>>> I want to include dom event mouseleave and mouseenter on prototype >>>> 1.6.0.2. >>>> Anyone have a idea to include it ? >> >>>> Thanks. >> >>>> Regards,- Tekst uit oorspronkelijk bericht niet weergeven - >> >>> - Tekst uit oorspronkelijk bericht weergeven - > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---
